show posts with range meta key

You can compare BETWEEN in the meta_query and you need to set the type too for NUMERIC. For example $args = array( ‘post_type’ => ‘my_custom_post_type’, ‘meta_key’ => ‘age’, ‘orderby’ => ‘meta_value_num’, ‘order’ => ‘ASC’, ‘meta_query’ => array( array( ‘key’ => ‘age’, ‘value’ => array( 5, 10 ), ‘compare’ => ‘BETWEEN’, ‘type’ => ‘NUMERIC’ ) )); … Read more

Loop posts based on permalink term

Got it to work with: $queried_object = get_queried_object () ; and ‘terms’ => $queried_object->slug, full code now: <?php $queried_object = get_queried_object () ; $posts = array ( ‘post_type’ => ‘writing’, ‘posts_per_page’ => -1, ‘tax_query’ => array( array( ‘taxonomy’ => ‘type’, ‘field’ => ‘slug’, ‘terms’ => $queried_object->slug, ), ), ); $loop = new WP_Query( $posts ); … Read more

Get posts in taxonomy randomly

You have syntax error in tax_query. ‘tax_query’ => array( array ( ‘taxonomy’ => $term->taxonomy, ‘field’ => ‘term_id’, // this is default value, so can be ommited ‘terms’ => $term->term_id, ) ) As you can read in Codex, possible values for field parameter are: term_id (default), name, slug or term_taxonomy_id. In this question you can read … Read more

how to get category`s slug in WP_Query loop?

get_the_category() retrieves WP_Term objects for all the categories assigned to the post. You can combine that with wp_list_pluck() to just get the slugs: $categories = get_the_terms( null, ‘project-category’ ); $category_slugs = wp_list_pluck( $categories, ‘slug’ ); $category_slugs will now be an array of slugs for the categories of the post.

Slow Query On Search

This is the query generated by the internal search function on WordPress. It is criticised for being inefficient, and there are a few drop-in replacements available as plugins. You may be able to find something that helps you by doing more research around these. For example: https://themeisle.com/blog/improve-internal-search-in-wordpress/ https://winningwp.com/best-wordpress-search-plugins/ I don’t have a specific recommendation to … Read more

Using get_posts to get posts based on a checkbox value with Advanced Custom Fields

OK, I found the answer here: WP Query post meta value Turns out you have to use the serialize php function due to how wordpress stores arrays in the database. function get_city_jobs() { $city = ($_GET[‘city’]); $city = trim(ucfirst($city)); $args = array( ‘post_type’ => ‘careers_post_type’, ‘numberposts’ => -1, ‘meta_query’ => array( array( ‘key’ => ‘city’, … Read more