Ni3singhchouhan

Untitled

Jul 7th, 2016
330
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. global $wpdb,$post;
  2. $request = 'B';
  3. $results = $wpdb->get_results(
  4. " SELECT * FROM $wpdb->posts
  5. WHERE post_title LIKE '$request%'
  6. AND post_type = 'product'
  7. AND post_status = 'publish';
  8. "
  9. );
  10.  
  11. if ( $results ) {
  12. foreach ( $results as $post ) {
  13. setup_postdata ( $post ); ?>
  14. <li>
  15. <?php echo $post->post_title; ?>
  16. </li>
  17. <?php
  18. }
  19. } else { ?>
  20. <div class="alert">No posts found for this particular letter.</div>
  21. <?php }
Add Comment
Please, Sign In to add comment