Get term slug by term id and then explode it

I guess the problem is here. $slug = $term->slug; $explodedSlug = explode(‘-‘, $_slug); you are passing an undefined array $_slug to explode function. the correct array is $slug. so your complete code should be something like below. function revised_featured_courses_query() { $meta_query = WC()->query->get_meta_query(); $tax_query = WC()->query->get_tax_query(); $tax_query[] = array( ‘taxonomy’ => ‘product_visibility’, ‘field’ => ‘name’, … Read more

Using variable in WordPress loop as criteria

You need an IN comparison and array if you want to match multiple values. array ( ‘key’ => ‘sale_or_rent’, ‘compare’ => ‘IN’, ‘value’ => array(‘Sale’, ‘Rent’), ),

WordPress shortcode in content, output in sidebar?

If you wanna show the content in sidebar if current post content has the shortcode then you should try has_shortcode function. Here is a demonstration- $content = get_the_content(); if( has_shortcode( $content, ‘your-shortcode’ ) ) { // The content has a [your-shortcode] short code, so this check returned true. } Hope it helps.

Calling function in loop causes repeat data

first of all, you could delete the return $ranking += 1; and replace by $ranking += 1;. We don’t know what happend in the template-parts/content, but don’t forget to add a little <?php wp_reset_postdata(); ?> just after your endwhile;.

Posts not showing

I think you need to check if you are in the properties post type archive before to manipulate the query, so it doesn’t affect to other archives. Also, you need to check if the actual $query is the main query, so other queries are not affected (the function is_main_query() does a different thing; it doesn’t … Read more

Custom Post type content within a slider

Since WP loaded with jQuery by default, you might be able to modify this script http://www.jqueryscript.net/rotator/Simple-Text-Slider-Rotator-with-jQuery-CSS.html to create a testimonials sliders. For randomizing your query, just put ‘orderby’ => ‘rand’ in your $args variable like this: $args = array( ‘post_type’ => ‘testimonials’, ‘orderby’ => ‘rand’); There are way more arguments you can learn from here: … Read more

Assign a template to a custom post type when displayed by the main loop on the home page

You are checking the source code of TwentySeventeen’s content.php selectively. The lines you quote are only about printing the publication time in case of a regular post. Directly below your lines the post/page title is printed regardless of post type. Regarding a) you don’t need to force anything, because as long as there is no … Read more