Support for custom post types (search, archives, feed, etc)

Posted in: Newspaper
Post count: 18

Hi, i’m working with custom post types in ambrosia.com.br and with those inserts in functions.php it works fine for search, feed and main query, but i could not show the custom posts on Archive pages. Can you please help with this? Thanks in advance,

function add_post_types_to_loop_and_feed($query) {
if ($query->is_feed() || $query->is_main_query() && $query->is_front_page()) {
$query->set(‘post_type’, array(‘post’, ‘custom1’, ‘custom2’, ‘custom3’));
}
}
add_action(‘pre_get_posts’, ‘add_post_types_to_loop_and_feed’);

function searchAll( $query ) {
if ( $query->is_search ) {
$query->set( ‘post_type’, array( ‘post’, ‘page’, ‘feed’, ‘custom1’, ‘custom2’, ‘custom3’));
}
return $query;
}
add_filter( ‘the_search_query’, ‘searchAll’ );

Post count: 22421
Post count: 18

Hi, thanks but we already have archive pages for custom post types, what we need is to show custom post types in the commom archive pages, alongside the “post” kind. For example, to display also events in the same archive pages.

Also, is possible to load the custom post types in the mega menu as well? Since it shows only “post” custom type. Thanks!

Post count: 23312

Hello ambrosiacombr,

Sorry, but the theme has not been designed to use custom post type in mega menu, unfortunately!

Thanks for your understanding!

Post count: 18

Besides that, what about the search, archive and so on? the theme says work with custom post types but does not really work…

Post count: 23312

Hello ambrosiacombr,

Sorry, but the custom posts type will do not appears on Archive and Search pages, sorry! You should display them to another custom page made by you. For more information about Custom Post Type, please read our documentation from here -> https://forum.tagdiv.com/custom-post-type-support/

Thanks for your understanding!

Viewing 6 posts - 1 through 6 (of 6 total)
The forum ‘Newspaper’ is closed to new topics and replies.