Custom endpoint filtering post by custom taxonomies

Solved!!! A friend of my found the way function get_latest_posts_by_term($request) { $parsed_args=[ ‘numberposts’ => 20, ‘orderby’ => ‘date’, ‘order’ => ‘DESC’, ‘post_type’ => ‘post’, ‘tax_query’ => array( array ( ‘taxonomy’ => $request[‘slug’], ‘field’ => ‘slug’, ‘terms’ => $request->get_param(‘name’), ) ), ]; $get_posts = new WP_Query; $posts= $get_posts->query( $parsed_args ); //$posts = get_posts($args); if (empty($posts)) { … Read more

How to display list of custom post taxonomy terms and their posts (if any)?

As per the docs: https://developer.wordpress.org/reference/functions/get_terms/ the way to get terms has changed in WP 4.5. It’s always good to keep the new way of dev. Thats said, this code seems to work on my side: $taxonomy = ‘city’; $args = array( ‘taxonomy’ => $taxonomy, ‘orderby’ => ‘count’, ‘order’ => ‘DESC’, ); $taxonomy_terms = get_terms( $args … Read more

Getting Same Description in All the Custom Taxonomy Posts

The correct WordPress loop structure is: // WP_Query arguments $args = array( ); // The Query $query = new WP_Query( $args ); // The Loop if ( $query->have_posts() ) { while ( $query->have_posts() ) { $query->the_post(); // do something } } else { // no posts found } // Restore original Post Data wp_reset_postdata(); Does … Read more

How to store the third party script with HTML code in the wordpress custom input field?

You are using esc_textarea() to output the content – so it’s doing exactly that. This is of course the correct thing to do with user input, so you have a few options here. Only ask for the embed id – then reconstruct it in php. Something like: <!– Meta box input example –> <input name=”thirdpartyvideoscript” … Read more