Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

benutzerfreund on "Show only posts with specific keyword in title"

$
0
0

I want to show all posts of a specific category containing a custom keyword in the post title.

What works is:

<?php
		$args = array('category_name' => 'interviews', 'posts_per_page' => '999' );
	    $the_query = new WP_Query( $args );
		while ( $the_query->have_posts() ) {
			$the_query->the_post();
			?>
			<li><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
			<?php
		} ?>

But when I add `'s' => 'peter' to $args, nothing is found (to get only interviews with Peter). Using only 's=peter' does't do the trick also.
But searching for 'peter' with the standard search box does bring up the correct posts.

Any hints?


Viewing all articles
Browse latest Browse all 8245

Trending Articles