Custom post type, custom taxonomy, query posts only from taxonomy (children of)

The problem was in not reading documentation carefully enough 😉 As it stands in http://codex.wordpress.org/Class_Reference/WP_Query in ‘tax_query’ part, “tax_query takes an array of tax query arguments arrays” so the correct part of code would be: $query_args = array( ‘post_type’ => ‘portfolio-type’, ‘paged’ => $paged, ‘tax_query’ => array( array( ‘taxonomy’ => ‘portfolio-category’, ‘field’ => ‘id’, ‘terms’ … Read more

Pagination on category.php and tag.php not working

If you merely want to modify posts_per_page for tag and category archive index pages, don’t use query_posts(); instead, filter the $query via pre_get_posts: function wpse87489_filter_pre_get_posts( $query ) { if ( ( is_category() || is_tag() ) && $query->is_main_query ) { $query->set( ‘posts_per_page’, ‘2’ ); } } add_action( ‘pre_get_posts’, ‘wpse87489_filter_pre_get_posts’ );

Show the latest post from child category?

Just change your query to search for the category you want. $qry = new WP_Query(‘category_name=paparazzi&showposts=1′); while($qry->have_posts()) : $qry->the_post(); That should most likely be all you need to do. And please don’t use query_posts. It alters the main query and can break things.

Exclude current sticky post

This should do: // Get sticky posts $sticky = get_option(‘sticky_posts’); rsort($sticky); $sticky = array_slice($sticky, 0, 3); // Check if current post is inside foreach ($sticky as $key => $value) if ($value === $GLOBALS[‘post’]->ID) { // … and remove unset($sticky[$key]); break; } $query = new WP_Query( array( ‘post__in’ => $sticky, ‘ignore_sticky_posts’ => 1, ) ); If … Read more

Display Posts with template on a Page

query_posts() is a horrible function and shouldn’t be used. Also it doesn’t has much to do with loading template, since it was originally designed to be used in template. Should not be used. If you are looking for logic of how WP picks template files from theme to load see Template Hierarchy. If you just … Read more

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