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 display featured images for all posts with certain taxonomy label?

Something quite rough that needs improvement but can give you a starting point, if I’ve understood your needs: use [dr] as shortcode marker where you want function my_dream_shortcode($atts, $content = null) { ob_start(); ?> <ul> <li class=”button” onClick=”get_data(‘corporate’)”>Corporate</li> <li class=”button” onClick=”get_data(‘sales’)”>Sales</li> <li class=”button” onClick=”get_data(‘support’)”>Support</li> </ul> <div class=”my_plugin_result”></div> <style> li.button{ list-style:none; padding:4px 10px; background-color:cadetblue; margin:10px; float:left; … 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

wp_query to find posts by year and month

Solved by creating custom sql queries. Request for years: SELECT count(*), $wpdb->posts.id as post_id_ts, YEAR( (SELECT $wpdb->postmeta.meta_value FROM $wpdb->postmeta WHERE $wpdb->postmeta.post_id = post_id_ts AND $wpdb->postmeta.meta_key = ‘docs_pubdate’)) AS years FROM $wpdb->posts WHERE $wpdb->posts.post_type=”document_base” AND $wpdb->posts.post_status=”publish” GROUP BY years which will return result like this: Array ( [0] => Array ( [count(*)] => 1 [post_id_ts] => … Read more