Although I have experience with PHP, WordPress is pretty new to me and I am struggling here.
I am trying to help a friend complete a theme. He works with several artists and each artist has a WP page named after the artist (i.e., Tom Jones) on which he wants to display only the posts about that artist. We define a tag for each artist ( Tom Jones ) with a slug like ( tom-jones )
Following the Codex, I am prepping the Loop in the template as follows:
$tags = get_tags();
//query_posts( array( 'tag' => $tag->slug ) );
query_posts( array( 'tag' => 'tom-jones' ) );
if( have_posts()) : while( have_posts() ) : the_post();
echo '<li id="feed<?php theID(); ?>" style="border-bottom:1px solid #404040;">';
echo '<table><tr><td width="40">';
echo '<img src="<?php echo get_post_meta($post->ID, 'image_path', true); ?>" />';
echo '</td><td><a href="';
the_permalink();
echo '">';
the_title();
echo '</a><br><span class="smTxt">Posted by ';
the_author();
echo ' on <em>';
the_time('F jS, Y');
echo '</em></span><br>';
the_excerpt();
echo '</td></tr></table></li>';
endwhile;
else:
echo '<h3>There are no posts.</h3>';
endif;
I would have thought that the query_post that is commented out would have grabbed the particular slug of the artist but it returns “No Posts”. When I hard code as it is now, it works as expected.
Any help is greatly appreciated.
Try this
This post may help you.
Update:
As you said
artistis a customtexonomyso try thisMust use
wp_reset_query()after the loop when you are usingquery_postsYou may read this post.
Update: (using WP_Query)