How to redirect a query string to a “virtual” subdirectory
How to redirect a query string to a “virtual” subdirectory
How to redirect a query string to a “virtual” subdirectory
Here I’ve written a function for you- function the_dramatist_get_product_cat_posts( $args = array() ) { $default_args = array( ‘taxonomy’ => ‘product_cat’, ‘get_post_type’ => ‘post’ ); $t = array(); $param = wp_parse_args($args, $default_args); $prod_terms = get_the_terms(get_the_ID(), $param[‘taxonomy’]); foreach ($prod_terms as $prod_term ) { $t[] = $prod_term->term_id; } $posts = get_posts(array( ‘post_type’ => $param[‘get_post_type’], ‘numberposts’ => -1, ‘tax_query’ … Read more
This answer is pretty covering for this I think: $args = array( ‘post_type’ => ‘brand’, ‘posts_per_page’ => 999, ‘meta_query’ => array( ‘relation’ => ‘OR’, array( ‘key’ => ‘wpcf-sorter’, ‘compare’ => ‘NOT EXISTS’, ), array( ‘key’ => ‘wpcf-sorter’, ‘compare’ => ‘EXISTS’, ), ), ‘orderby’ => array( ‘meta_value’ => ‘DESC’, ‘date’ => ‘DESC’ ), ); That should … Read more
I see two issues in your code. First, you pass what could be a string into post__not_in, which accepts an array of posts IDs (that’s fine if your option holds an array of IDs, but always good to verify). Second, you seem to be repeating the same thing twice: you modify the query with pre_get_posts … Read more
Red faced – but happy to share the results and save someone else the pain. I have been chasing a ghost for the last two days, there is a default number of posts the wp_query returns which is page specific. It seems to be set to 10 posts on the page I am on. All … Read more
First Question’s Answer: For filtering based on your terms first letter you need to filter the query, which you can do with the terms_clauses hook. By putting the below code block in your theme’s functions.php you can do that- function the_dramatist_filter_term_clauses( $clauses ) { remove_filter(‘term_clauses’,’the_dramatist_filter_term_clauses’); $pattern = ‘|(name LIKE )\’%(.+%)\’|’; $clauses[‘where’] = preg_replace($pattern,’$1 \’$2\”,$clauses[‘where’]); return … Read more
By default, WordPress searches by keyword. To use a custom query variable for search, you would have to register the custom query variable using query_vars function wpse250276_register_query_vars( $vars ) { $vars[] = ‘ait-locations’; return $vars; } add_filter( ‘query_vars’, ‘wpse250276_register_query_vars’ ); Then you need to use pre_get_posts to alter search query and include your custom taxonomy … Read more
Search Filter With Custom Taxonomy and Custom Fields : How do I handle it via plugin?
try like this: if ($obj->have_posts()){ while($obj->have_posts()){ $obj->the_post(); $slug = get_the_tags(); $obj->the_title(); echo “<br/>”; $queryH = array(“cat”=>13,”order”=>”ASC”,”posts_per_page”=>-1,”tag__in”=>$slug); $objH = new WP_Query($queryH); if ($objH->have_posts()){ while($objH->have_posts()){ $objH->the_post(); $objH->the_title(); echo “<br/>”; } } } }
I’m pretty sure it’s because you’ve got mixed nested quotes when you’re setting $CatIDsCode. So this should fix it: $camp_posts_bynumber = new WP_Query (array (‘cat’ => $CatIDs)); P.S. Move $CatIDs= implode(‘,’, $out); outside of the foreach loop. 🙂