Modifying date filter on admin page for custom post type to link to custom field

Use the pre_get_posts action to override the default query. In the admin, a date query will be the query var m in the format YYYYMM. Assuming your meta dates are stored the same as MySQL dates (YYYY-MM-DD), you can use the following: function wpse_189824_date_meta_query( $wp_query ) { if ( is_admin() && $wp_query->is_main_query() && $wp_query->get( ‘post_type’ … Read more

How to search map address in custom post type?

You need a meta_query something like this: $args = array( ‘post_type’ => ‘shop’, ‘meta_query’ => array( array( ‘key’ => ‘map-location’, ‘value’ => ‘London’, ‘compare’ => ‘LIKE’ // the = operator might work depending on how your data is stored ), ) ); Note: I am making some assumptions about how ACF stores data.

Is there a way to connect a custom post type to another custom post type’s taxonomy? (specific to locations)

I didn’t know that I can register a taxonomy for more than 1 CPT/post type! register_taxonomy( ‘location’, array( ‘offer’, ‘store’ ), array( ‘label’ => __( ‘Location’, ‘themeify’ ), ‘hierarchical’ => true, ‘labels’ => array( ‘name’ => __( ‘Location’, ‘themeify’ ), ‘singular_name’ => __( ‘Location’, ‘themeify’ ), ‘menu_name’ => __( ‘Location’, ‘themeify’ ), ‘all_items’ => __( … Read more

Archive slider for CPT

The slider script is called with the following lines of code if ( is_front_page() && ‘slider’ == get_theme_mod( ‘featured_content_layout’ ) ) { wp_enqueue_script( ‘twentyfourteen-slider’, get_template_directory_uri() . ‘/js/slider.js’, array( ‘jquery’ ), ‘20131205’, true ); wp_localize_script( ‘twentyfourteen-slider’, ‘featuredSliderDefaults’, array( ‘prevText’ => __( ‘Previous’, ‘twentyfourteen’ ), ‘nextText’ => __( ‘Next’, ‘twentyfourteen’ ) ) ); } You just need … Read more

Get all of user’s custom post types in WP Admin for plugin

By passing the _builtin argument to get_post_types(), only WordPress default post types will be returned. Instead, just pass public as an arguement, Here’s an example of output on a development site with WooCommerce activated: var_dump(get_post_types([‘public’ => true])); //result array(4) { [“post”]=> string(4) “post” [“page”]=> string(4) “page” [“attachment”]=> string(10) “attachment” [“product”]=> string(7) “product” } With no … Read more