WP Query to displaying date and posts for that date?

I was able to do this using the following: $args = array( ‘post_type’ => ‘show’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => -1, ‘orderby’ => ‘meta_value’, ‘meta_key’ => ‘show_date’, ‘order’ => ASC ); $query = new WP_Query( $args ); if( $query->have_posts() ) { $day_check = ”; while( $query->have_posts() ): $query->the_post(); $day = date(‘Y-m-d’, strtotime(get_field(‘show_date’))); if ($day != … Read more

WP_Query is printing out only one post when posts_per_page is set to multiple

you are re-initializing the out variable that is why it shows only one product // Custom Post Type for Use Cases page slider function create_post_type() { register_post_type( ‘use_cases’, array( ‘labels’ => array( ‘name’ => __( ‘Use Cases’ ), ‘singular_name’ => __( ‘Use_Case’ ) ), ‘public’ => true, ‘has_archive’ => true, ) ); } add_action( ‘init’, … Read more

How to create an advanced filter search?

Try this: PHP add_action( ‘wp_ajax_my_adv_search’, ‘ajax_my_adv_search’ ); add_action( ‘wp_ajax_nopriv_my_adv_search’, ‘ajax_my_adv_search’ ); function ajax_my_adv_search() { if ( ! check_ajax_referer( ‘my-adv-search’, ‘q_nonce’, false ) ) { echo ‘session_expired’; wp_die(); } $post_type = isset( $_POST[‘q_post_type’] ) ? $_POST[‘q_post_type’] : ”; $taxonomy = isset( $_POST[‘q_taxonomy’] ) ? $_POST[‘q_taxonomy’] : []; $year = isset( $_POST[‘q_year’] ) ? $_POST[‘q_year’] : ”; … Read more

How to filter search results by post type?

By all rights it should work, here’s the same thing applied to my own site: tomjn.com/?s=talk&post_type=tomjn_talks vs tomjn.com/?s=talk . Something else is the problem Specifically, if you replace the main query with a query_posts call or a WP_Query, that query won’t take into account parameters passed via the URL unless explicitly passed through manually. Instead, … Read more

Fetch ID’s associated with a custom post type when translated with WPML?

NOTE: I’m not giving a full answer to your question but trying to give some snippets that may help in WPML-based project. I’ve used this function: function get_the_translated_ID($id){ if (!class_exists(‘sitepress’) return $id; global $sitepress; $type=get_post_type($id); return icl_object_id( $id, $type, false, $sitepress->get_default_language()); } This allows, for example, to search for custom_meta values of the original post … Read more

How to create an array for a CPT post ID to use in an IF/WHILE statement

You can use the fields parameter of WP_Query to get just IDs back, then iterate over them with a foreach loop: $args = array( ‘post_type’ => ‘services’, ‘posts_per_page’ => -1, ‘fields’ => ‘ids’, ); $query = new WP_Query( $args ); if( $query->have_posts() ){ foreach( $query->posts as $id ){ the_field( ‘the_field’, $id ); } } else … Read more

How to filter custom taxonomy categories on archive?

Recap: You created a custom post type = “downloads” and a custom taxonomy = “downloads_category” with a rewrite to “categoria-de-downloads” First: The “is_tax” at the head of your archive.php is failing because the name of your custom taxonomy should be “downloads_category“; it must be spelt with an underline rather than a hyphen (Codex). You also … Read more

How to make a custom taxonomy selectable in post publish area?

The reason it does not show up automatically is because it requires REST enabled to display. By default, show_in_rest is set to false when registering taxonomies and post types. There’s currently a Trac Ticket #42785 open to change this default functionality. So in short when registering a taxonomy while using the Block Editor you’ll need … Read more