Hello,
I am a newbie when it comes to coding and I want to construct a WP_Query based on the codex.
https://codex.wordpress.org/Class_Reference/WP_Query
The arguments are:
5 posts
from custom post type “os_calendar”
in taxonomy called “formula1”
showing the thumbnail (preferably my defined custom thumbnail size called “spotlight”) & post title in a list <li> format
Your help is much appreciated!
Many thanks,
Andy
I am currently using
<?php
$args = array(
'post_type' => 'os_calendar',
'taxonomy' => 'calendar_event_type',
'post_per_page' => 5);
$recentPosts = new WP_Query( $args );
$recentPosts->query('showposts=5');
while ($recentPosts->have_posts()) : $recentPosts->the_post();
?>
<div <?php post_class(); ?> id="post-<?php the_ID(); ?>">
<h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
</div>
<?php endwhile; ?>
<?php wp_reset_query(); ?>
but nothing is returned… i must be doing sth wrong somewhere…
force
April 10, 2013, 10:35am
3
Check your taxonomy. It differs between what you originally posted and what’s in your code.
Also:
$recentPosts = new WP_Query( $args );
$recentPosts->query('showposts=5');
The second statement is unnecessary. The posts_per_page argument takes care of this.
i think my theme is to be blamed… Here is what the author said:
Yes, the pre_get_posts filter that is used in functions/custom.php lines 23 - 40 alters the query. You should add suppress_filters to your query.