Custom query for certain post type OR another post type with a certain category

First, take a look at this: https://developer.wordpress.org/reference/classes/wp_query/ You can filter by querying by post type, or in a single query (code between /* */). <?php //This is the first query $query_A = array( ‘post_type’ => ‘post_type_A’, ‘post_status’ => ‘publish’, //’cache_results’ => true, ‘posts_per_page’ => 10, ‘orderby’ => ‘date’, ‘order’ => ‘DESC’, ‘fields’ => ‘ids’//add by … Read more

How to get only post=’product’

If I understand you, what you are doing is wildly complicated. All you should need is a simple pre_get_posts filter: add_filter( ‘pre_get_posts’, ‘modified_pre_get_posts’ ); function modified_pre_get_posts( $query ) { if ( $query->is_search() ) { $query->set( ‘post_type’, ‘product’ ); } return $query; } Plus your filter that adds DISTINCT. post_type is a query parameter rolled into … Read more

How do i retrive a post from a custom post type

I’m not sure that I completely understand your question, but if you’re just looking for an array of movies that are of the type distributie, based on the ID of the current Loop object, this will do it: $args = array( ‘post_type’ => ‘movies’, ‘meta_key’ => ‘distributie’, ‘meta_value’ => get_the_ID() ) $get_distributie_movies = get_posts( $args … Read more

add post type pram to wp shortcode

Do you want to be able to switch between post types? If not, seems to me you could just duplicate the same functionality as you’re using with the per_page parameter, meaning: In your shortcode function just add a data attr to the #container-async div for the post_type(s). <div id=”container-async” data-paged=”<?php echo $a[‘per_page’]; ?>” data-posttype=”<?php echo … Read more