adding tax_query to $query_string

the best way of doing this is WP_Query $query = new WP_Query( ‘post_type’ => ‘post’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘my_custom_tag’, ‘slug’ => ‘slug’, ‘terms’ => array( ‘my_tag_slug’ ), ‘operator’ => ‘in’, ), ) ); and you should do the ajax callback like this add_action( ‘wp_ajax_my_action’, ‘my_action’ ); function my_action(){ //my custom code … … Read more

Homepage Loop Somehow Breaks Styling Of Post Grid

I assumed that you have the static page works well before you sliced up and make it into wordpress theme development. I had the same problem, But I managed to solve this by doing some hints: Check the slicing of the element you’re about to loop. Only loop the element of the post. Perhaps you … Read more

Multiple loops in set intervals with code in between

As stated by the codex, have_posts starts, steps through or rests the loop. check codex here. In your code, when entering the second or n-th while, the posts loop is already started, so it steps to the next post, that’s why it skips 6th element and starts over on the last while loop. I would … Read more

Style first 3 posts differently and use a 2nd loop to get rest of posts / offset and pagination broken

My advice would be to never use query_posts. Instead use a custom query or the pre_get_posts hook for both instances and always make sure you call wp_reset_postdata after your custom query. BUT becase your nav function references the global $wp_query, you would have to use query_posts passing the paged parameter to it. <?php get_header(); ?> … Read more

How to fix pagination for custom loops?

The Problem By default, in any given context, WordPress uses the main query to determine pagination. The main query object is stored in the $wp_query global, which is also used to output the main query loop: if ( have_posts() ) : while ( have_posts() ) : the_post(); When you use a custom query, you create … Read more

WordPress redundant posts based on meta field

I ended create another custom post type to manage the schedule and I created a relation to the existing films custom post type: – Films (all films without tv guide) – TV schedule (each post represents time in the tv guide and can only be related to one movie). I then enabled future posts to … Read more

Adding comma to while loop wpquery output

Try with this: <?php $args = array( ‘post_type’ => ‘product’, ‘post_status’ => ‘publish’, ‘meta_key’ => ‘views’, ‘orderby’ => ‘meta_value_num’, ‘order’=> ‘DESC’, // sort descending ); // Custom query. $query = new WP_Query( $args ); // Check that we have query results. if ( $query->have_posts() ) { // Start looping over the query results. while ( … Read more

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