[Resolved] Taxonomie for pages -> colums for pages in archives

Home Forums Support [Resolved] Taxonomie for pages -> colums for pages in archives

Home Forums Support Taxonomie for pages -> colums for pages in archives

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #2237966
    Mi

    Hello again,

    i read a lot in the forum and found a lot of helpful stuff, but not exactly what I am looking for.
    My website is based mostly on pages and because there are so many of them I want to add categorys and tags to them. I did this via adding this in the functions.php:

    function add_taxonomies_to_pages() {
     register_taxonomy_for_object_type( 'post_tag', 'page' );
     register_taxonomy_for_object_type( 'category', 'page' );
     }
    add_action( 'init', 'add_taxonomies_to_pages' );
     if ( ! is_admin() ) {
     add_action( 'pre_get_posts', 'category_and_tag_archives' );
     
     }
    function category_and_tag_archives( $wp_query ) {
    $my_post_array = array('post','page');
     
     if ( $wp_query->get( 'category_name' ) || $wp_query->get( 'cat' ) )
     $wp_query->set( 'post_type', $my_post_array );
     
     if ( $wp_query->get( 'tag' ) )
     $wp_query->set( 'post_type', $my_post_array );
    }
    

    Works perfect. – But now I can´t give the pages-previews in the archives-page the same design as the posts. (see here -> https://www.ffcorner.com/testwp/tag/tifa/ First Entry is a post, the next are pages)

    I tried it with css and with the Colums to custom post types filter -> https://docs.generatepress.com/article/using-columns-in-the-blog/#adding-columns-to-your-custom-post-type
    but I could´t get it to work.

    I didn´t want to try the WPSP, because I´ve read that there will be no more updates and that it is coming with the new GenerateBLock version. Should I wait for this or is there any other way I can go for now?

    Thank you!

    #2238020
    David
    Staff
    Customer Support

    Hi there,

    the GP blog columns apply to the post post type.
    But we can filter in other post types using the snippet provided here:

    https://docs.generatepress.com/article/using-columns-in-the-blog/#adding-columns-to-your-custom-post-type

    Which should be:

    
    add_filter( 'generate_blog_columns', function( $columns ) {
        if ( 'page' === get_post_type() && ! is_singular() ) {
            return true;
        }
    
        return $columns;
    } );
    #2238191
    Mi

    I already tried this ….. and it didn’t work. Now it does ^^’
    Thanks a lot and sorry for the circumstances!

    #2238206
    David
    Staff
    Customer Support

    No problems – glad to hear it is working!

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.