Page title in post query

Your original code has a typo – the ampersand is used to separate arguments, so it should be: ‘posts_per_page=10&category_name=” . $post->post_title However, since this is a new query in addition to the default, a new instance of WP_Query should be used instead of query_posts: $args = array( “posts_per_page’ => 10, ‘category_name’ => $post->post_title ); $related … Read more

query_posts not reading correct categories

Firstly, avoid query_posts, instead use WP_Query or hook into pre_get_posts. query_posts is bad practice, a performance hit/slowdown, and a source of many troubles. As a fulltime developer I wouldn’t very strongly recommend against all use of that function, and many prominent WordPress developers and WordPress Core devs would say and do say the same. The … Read more

Related Posts: Notice: Undefined offset: 0

When you use wp_list_pluck on $terms what you get is an array where the key is the same as the value. If you dump the contents of $term_ids you’ll see something like: array( [42] => 42, [56] => 56 } The code in query.php tries to reference the zero index of the term_ids array, but … Read more

How to show the number of each post has been read in a while loop?

the_views() is not a built in function of WordPress. In fact, WordPress does not, by default, log the number of views of posts. There are probably several plug-ins that exist which add this functionality. The only one I have ever used (and its one I’ve never had any problems with) is WP-Postviews http://wordpress.org/extend/plugins/wp-postviews/.

How to place an image after Nth number of posts in query_posts

Multiple nested if statements can create a mess you might look into using a switch for this case. Something like: //your $args $the_switch_query = new WP_Query($args); while ( $the_switch_query ->have_posts() ) : $the_switch_query ->the_post(); $query_number = $the_switch_query->current_post + 1; //count them switch ($query_number){ case 1; echo “post one”; break; case 5; echo “post five”; break; … Read more

Problem with different query loops (and “main loop”) on category template page!

In order to provide more-specific help, we’ll need to know greater detail regarding exactly what’s happening that you don’t expect, or what’s not happening that you expect to happen, or what is happening differently from what you expect. That said, there are at least two things that will likely help you: Use descriptive and unique … Read more

Display custom posts randomly in custom taxonomy archive

I’ve finally found the solution thanks to a friend of mine: exploiting get_queried_object() we can set the object name in the script as follows: <?php $obj=$wp_query->get_queried_object(); $args=array( ‘tax_query’ => array( array( ‘taxonomy’ => ‘areas’, ‘field’ => ‘slug’, ‘terms’ => $obj->name ) ), ‘orderby’ => ‘rand’ ); query_posts($args); ?> Hope this can help. Enjoy! 🙂

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