How Can I Remove Custom Post Type Slug From URL
The best way to do this is via .htaccess. Take a look at this answer: https://stackoverflow.com/questions/7710411/how-to-remove-part-of-url-with-htaccess
The best way to do this is via .htaccess. Take a look at this answer: https://stackoverflow.com/questions/7710411/how-to-remove-part-of-url-with-htaccess
It seems like you need to override the canonical redirection on custom post types to get the pagination to work. It had nothing to do with the custom query used and described above, as that worked perfectly fine on a normal page and now also on a custom post type. I figured out that I … Read more
First of all themes need to use add_theme_support() in the functions.php file to tell WordPress which post formats to support by passing an array of formats like so: add_theme_support( ‘post-formats’, array( ‘aside’, ‘gallery’ ) ); Note that you must call this before the init hook gets called! A good hook to use is the after_setup_theme … Read more
Delete map_meta_cap. it will appear in your dashboard ‘map_meta_cap’ => true, //remove this line why are you trying to restrict all those capabilities? IT look likes you’ve not given yourself capability to see the post with the restrictions there… if you don’t know why those are there, you may not need any of these lines: … Read more
This works for me: function namespace_add_custom_types( $query ) { if( is_tag() && empty( $query->query_vars[‘suppress_filters’] ) ) { $query->set( ‘post_type’, array( ‘YOUR_CUSTOM_POST_TYPE’, ‘nav_menu_item’)); return $query; } } add_filter( ‘pre_get_posts’, ‘namespace_add_custom_types’ );
Just set post_type to an array of types, and posts_per_page to 1 and you’ll get the most recent post from those types. $args = array( ‘post_type’ => array( ‘type_1’, ‘type_2’ ), ‘posts_per_page’ => 1 ); $latest = new WP_Query( $args );
Nevermind. I forgot to add this in my functions.php. I will leave the answer here so it may help others. //Tag pagination pages function wpd_custom_types_on_tag_archives( $query ){ if( $query->is_tag() && $query->is_main_query() ){ $query->set( ‘post_type’, array( ‘portal’ ) ); } } add_action( ‘pre_get_posts’, ‘wpd_custom_types_on_tag_archives’ );
You can make CPT’s have “slugless” permalinks fairly easily: register_post_type( ‘service’, [ ‘hierarchical’ => true, ‘public’ => true, // Other args, no need for “rewrite” ]); // Change service to top-level permalink. add_permastruct( ‘service’, ‘%service%’, [ ‘with_front’ => false, ‘paged’ => false, ‘feed’ => false, ]); // Remove all default service rewrite rules. add_filter( ‘service_rewrite_rules’, … Read more
The meta_query parameter must be change in an array of array for a single custom field handling: ‘meta_query’ => array( array( ‘key’ => ‘min_event-start’, ‘value’ => date(‘Y-m-d’), ‘compare’ => ‘>’, ) ) You will the informations WP_Query in the Single Custom field handling part Hope it will work with this.
From what you describe these ads are separate pieces of information which you want to order and display based on their properties. That would mean storing them as custom posts is still the way to go. After all, posts are the way WordPress stores chunks of related information. That doesn’t mean they have to be … Read more