wordpress query loop

erezabou
erezabou used Ask the Experts™
on
hi expert,

Here is my loop:

query_posts('cat=23&posts_per_page=3');
        if( have_posts() ) : while( have_posts() ) : the_post();

I need to change in order to get only cat=23 and post subject starting with "Post"

Thanks for your help
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Hello. i think that will do it.
query_posts('cat=23&left(posts_title,4)="Post"');
        if( have_posts() ) : while( have_posts() ) : the_post();

please feedback
Consultant Instructor
Commented:
Try this:
<?php
global $wpdb;
$querystr = "SELECT P.* 
FROM {$wpdb->prefix}posts P
LEFT JOIN {$wpdb->prefix}term_relationships TR ON (P.ID = TR.object_id)
LEFT JOIN {$wpdb->prefix}term_taxonomy TT ON (TR.term_taxonomy_id = TT.term_taxonomy_id)
WHERE TT.taxonomy = 'category'
AND TT.term_id = 23
AND P.post_title LIKE 'Post%'
ORDER BY P.ID ASC";

$results = $wpdb->get_results( $querystr, OBJECT );

if( $results ) :
	global $post;
	foreach( $results as $post ) :
		setup_postdata( $post );
?>
<?php the_title(); // You can use the same tags as if it were in the 'loop' ?>
<?php
	endforeach;
endif;
?>

Open in new window

Jason C. LevineDon't talk to me.

Commented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial