Multiple WP_Query args combinations according to post type
Multiple WP_Query args combinations according to post type
Multiple WP_Query args combinations according to post type
Please check the code where you wrote array_intersect. array_intersect function return null array if it doesn’t find any match. So your condition checking using !array_intersect is invalid.
I need to know what query I have to use on the AJAX to get the output? In the comments, you said, “I am looking to search only for categories“, so for that, you can simply use get_categories() (or get_terms() for custom taxonomies) and set the search arg to the submitted search keyword: // Get … Read more
Use get_cat_ID(‘categoy name’) https://developer.wordpress.org/reference/functions/get_cat_id/ <?php $category_id = get_cat_ID(‘Category Name’); if($category_id > 0){ echo ‘category exists’; }else{ echo ‘category NOT exists’; } ?>
I believe you should be able to use this: global $post; $page_slug = $post->post_name; Where $page_slug is the variable you’re looking for. This has a pretty good explanation of why that works: https://blog.wplauncher.com/get-current-page-slug-wordpress/
WP_Query not ordering correctly
You can do this with a meta_query. The get_posts() function accepts everything that WP_Query accepts so it could look something like this: $orders = get_posts( array( ‘numberofposts’ => -1, ‘posts_per_page’ => -1, ‘post_type’ => ‘executive-orders’, ‘orderby’ => ‘date’, ‘order’ => ‘DESC’, ‘meta_query’ => array( ‘relation’ => ‘AND’, ‘eo_type’ => array( ‘key’ => ‘eo_type’, ‘value’ => … Read more
For 99% of cases, no, you can’t. Serialised data is not something you can search, and that is the fundamental problem. Not how to search it, but that it was serialised to begin with. Serialising is unnecessary. This is for the same reasons you cannot unscramble an egg, serialised data, especially PHP serialised data, is … Read more
On post insert/update, set the post’s menu_order as the maximum of the numeric MMDD values of original_date and featured_date. Maybe set the menu order in the format 1MMDD to avoid a leading zero. Then we can order the custom type posts by the menu order very fast with: WP_Query( [ ‘post_type’ => ‘custom_post_type’, ‘orderby’ => … Read more
adding dynamic/multiple slug values in ‘option_none_value’