How to redirect all pages of a custom post type [duplicate]

As stated by Milo it looks like it a duplicate of [How to disable the single view for a custom post type?] <?php add_action( ‘template_redirect’, ‘subscription_redirect_post’ ); function subscription_redirect_post() { $queried_post_type = get_query_var(‘post_type’); if ( is_single() && ‘subscription’ == $queried_post_type ) { wp_redirect( pricingpageURL, 301 ); exit; } } ?> Just swap our pricingpageURL with … Read more

Re-order posts in query after

Given that meta is cached inside page load it should be reasonably performant to do it like this (not tested): usort( $wp_query->posts, function ( $post_a, $post_b ) { $a = get_post_meta( $post_a->id, ‘key’, true ); $b = get_post_meta( $post_b->id, ‘key’, true ); if ( $a == $b ) { return 0; } return ( $a … Read more

How to make an archive page displaying posts in a date range

Saving the date in post meta is a slightly more sane approach, the post_date column was not designed with your use case in mind. You may get weird results with dates before the Unix epoch (January 1, 1970). Then it’s just a simple meta_query to load posts between dates, no filter necessary. $start=”1900-01-01″; $end = … Read more

Filters post in admin with dropdown select, custom post type

Thank you so much, it’s working. Here is my modified code: function wpse45436_posts_filter( $query ){ global $pagenow; $type=”post”; if (isset($_GET[‘post_type’])) { $type = $_GET[‘post_type’]; } if ( ‘post’ == $type && is_admin() && $pagenow ==’edit.php’ && isset($_GET[‘ADMIN_FILTER_FIELD_VALUE’]) && $_GET[‘ADMIN_FILTER_FIELD_VALUE’] != ” && $query->is_main_query() ) { $query->query_vars[‘meta_key’] = ‘n_de_ldition’; $query->query_vars[‘meta_value’] = $_GET[‘ADMIN_FILTER_FIELD_VALUE’]; } } By targetting … Read more

Custom template for post type not working

get_post_format and get_post_type are completely different. Post Formats can be one of the following: ‘standard’ (default one) ‘aside’ ‘chat’ ‘gallery’ ‘link’ ‘image’ ‘quote’ ‘status’ ‘video’ ‘audio’ And shopping is the post type you have created and not post format. You can add post format for the post type(shopping) like this add_post_type_support( ‘shopping’, ‘post-formats’ );

Custom Post Type Query multiple Taxonomy Terms

Query Arguments: If $input_terms is the input array of term slugs, then you should be able to use (if I understand the question correctly): $property = [ ‘post_type’ => ‘properties’, ‘paged’ => $paged, ‘tax_query’ => [ [ ‘taxonomy’ => ‘features’, ‘field’ => ‘slug’, ‘terms’ => $input_terms, ‘operator’ => ‘AND’, ] ], ]; where we added … Read more