Get attachment if matches a variable

$attachments holds array of posts, you are missing something like: $attachment = $attachments[0]; or foreach( $attachments as $attachment ) Update Nope, like this: foreach( $attachments as $attachment ) if ($attachment->post_title == $programme) { echo the_attachment_link($post->ID, false); break; }

How do i put a sidebar on my post permalink page?

The template for the display of a single post is single.php Add <?php get_sidebar(); ?> in the second last line of that file just above <?php get_footer(); ?> and the sidebar will show. Note: This will get overwritten, if you ever update the theme.

Viewing category won’t show up Custom post type posts

Blockquote Taxonomy category with a term with id 9 dosen’t have a posts with post type blog. Are you sure that you using native category taxonomy for CPT blogs posts? function query_report($sql){ var_dump($sql); echo ‘<hr>’; return $sql; } add_filter(‘query’, ‘query_report’); query_posts($your_arguments); remove_filter(‘query’, ‘query_report’);

Password-protected Posts lead to 404 Error

Ok, figured it out myself! I had used add_filter to customize the password form in order to add css classes. Everything in add_filter was either old or simply wrong. I found it in a tutorial, but this has been a lesson to me. Never trust code found on the web unless it from the Codex … Read more