Multi level archive

This is a direction. Not tested but you have an idea. <?php // get current term $term = get_term_by( ‘slug’, get_query_var(‘term’), get_query_var(‘taxonomy’) ); // get parent term $parent = get_term($term->parent, get_query_var(‘taxonomy’) ); // get children $children = get_term_children($term->term_id, get_query_var(‘taxonomy’)); $taxonomy = ‘business-types’; if ( empty($parent->term_id) ) { echo ‘<a href=”‘ . esc_url( get_term_link( $term ) … Read more

For each 3 posts, show a different post type

There are several ways to do this. Here’s an easy one. Let’s say you want to mix 9 ‘daily’ posts and 3 ‘quotes’. First you would have to get those posts: $dailies = get_posts(array(‘posts_per_page’ => 9, ‘post_type’ => ‘daily’)) $quotes = get_posts(array(‘posts_per_page’ => 3, ‘post_type’ => ‘quote’)) Next you would loop through them like this: … Read more

Counting number of images from loop

You can get images with foreach loop but first you have to print_r($images) and then get the value of the array something like this $images[‘image’] or $images[‘src’] or $images[‘url’] etc. But first check is there any record where you are getting get_sub_field(‘image’) all images. <?php if ( $images = get_sub_field(‘image’) ) : print_r($images); foreach($images as … Read more

WP_Query causing links to not work

I’m sorry. I didn’t create a single.php file. In my learnings I have discovered that if no single.php file exist then WordPress falls back to index.php. So the link were actually working but just using the same template. Again im sorry for wasting your time.

modifying the loop multiple times with arguments passed through ajax to wp_query

You can use wp_localize_script to save your current query to JS variable. Then you should send it using ajax and modify it and send it back to have access to it in the future. global $wp_query; wp_localize_script( ‘ajax-pagination’, ‘ajaxpagination’, array( ‘ajaxurl’ => admin_url( ‘admin-ajax.php’ ), ‘query_vars’ => json_encode( $wp_query->query ) )); This article should help … Read more