Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate
Sign In | Create Account

Advertising

Paste Description for Query based on custom fields

Forum thread:
http://wordpress.org/support/topic/121011

Query based on custom fields
Thursday, June 7th, 2007 at 10:43:39am MDT 

  1. <?php
  2. get_header();
  3. ?>
  4.  
  5. <?php
  6.  
  7.  $querystr = "SELECT wposts.* FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta WHERE wposts.ID = wpostmeta.post_id AND wpostmeta.meta_key = 'paragraf' AND wposts.post_status = 'publish' AND wposts.post_type = 'post' ORDER BY wpostmeta.meta_key ASC";
  8.  
  9. $pageposts = $wpdb->get_results($querystr, OBJECT);
  10.  
  11.  ?>
  12.  
  13. <?php if ($pageposts): ?>
  14. <?php foreach ($pageposts as $post): ?>
  15. <?php setup_postdata($post); ?>
  16.  
  17. <h1 id="post-<?php the_ID(); ?>"><?php the_title(); ?></h1>
  18. <h2><?php echo get_post_meta($post->ID, "gdzie", true); ?></h2>
  19.  
  20. <?php the_content(__('(more...)')); ?>
  21.  
  22. <div class="post_info">
  23. Dodane: <?php the_date(); ?> |
  24. Folder: <?php the_category(',') ?> |
  25. Komentarze: <?php comments_popup_link(__('(0)'), __('(1)'), __('(%)')); ?> |
  26. <?php edit_post_link(__('Edit This')); ?>
  27. </div>
  28.  
  29. <?php comments_template(); // Get wp-comments.php template ?>
  30.  
  31. <?php endforeach; ?>
  32. <?php else : ?>
  33.  
  34. <?php _e('Sorry, no posts matched your criteria.'); ?>
  35.  
  36. <?php endif; ?>
  37.  
  38. <?php posts_nav_link(' — ', __('&laquo; Previous Page'), __('Next Page &raquo;')); ?>
  39.  
  40. <?php get_footer(); ?>

advertising

Update the Post

Either update this post and resubmit it with changes, or make a new post.

You may also comment on this post.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.

fantasy-obligation
fantasy-obligation