Thursday, September 1, 2022
HomeWordPress Developmentclasses - Present customized put up kind on put up class web...

classes – Present customized put up kind on put up class web page does not work / breaks naviagation


I am making some modifications to a website created by another person. I do not work with WP usually so I am not too conversant in all of the hooks, and so on.
On this website they’ve regular posts and a customized put up kind referred to as landingpages.
These touchdown pages use the identical classes because the posts.

We’ve got an summary web page of all posts and landingpages collectively which appears to work effective. On the web page we even have an inventory of all classes. In the event you click on on a class it ought to present all posts and landingpages which have that class chosen.

That is the place issues go fallacious. I can not seem to get these class pages to work the best way they need to. It really works effective when solely exhibiting the posts (default conduct) however when I attempt to add the landingpages in there it reveals the posts and landingpages however the navigation disappears.

I discovered the next code (cannot keep in mind which website) which ought to make it work however on this case the navigation disappears

operate test_add_cpt_to_archive_page( $question ) {
    if( (is_category() || is_tag()) && $query->is_archive() && empty( $query->query_vars['suppress_filters'] ) ) {
        $query->set( 'post_type', 'any');
    }
    return $question;
}
add_filter( 'pre_get_posts', 'test_add_cpt_to_archive_page' );

Additionally setting the post_type to an array array('put up','landingpages') does not work both.

The one articles I discover on how to do this use the identical code snippet as I posted right here. Most different articles speak about a customized class web page for a customized put up kind, as a substitute of exhibiting customized put up varieties on the conventional class pages.

I am most likely making a rookie mistake right here, so any assist or suggestions can be a lot appreciated!

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments