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

Exclude a ‘portfolio’ custom category?

Please take a look at this example; $args = array( ‘post_type’ => ‘post’, ‘tax_query’ => array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘movie_genre’, ‘field’ => ‘slug’, ‘terms’ => array( ‘action’, ‘comedy’ ) ), array( ‘taxonomy’ => ‘actor’, ‘field’ => ‘id’, ‘terms’ => array( 103, 115, 206 ), ‘operator’ => ‘NOT IN’ //you must set the … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)