[Resolved] Custom Taxonomy Archive page

Home Forums Support [Resolved] Custom Taxonomy Archive page

Home Forums Support Custom Taxonomy Archive page

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #693655
    David

    I am trying to get my custom taxonomy pages to reflect the same settings I am applying to my standard archive page (https://learn04.digitaldiplomats.com/category/news-and-info/). But it does not.

    Is this achievable without coding? If coding is need, what files will need to be created to get the loop integrated in the custom taxonomy/post type pages?

    Thanks

    #693781
    Tom
    Lead Developer
    Lead Developer

    Hi David,

    We’ll need to add a couple filters to achieve this.

    Just to confirm, which settings should we be targeting? I’m seeing masonry, but is there anything else?

    #693787
    David

    Hi Tom,

    For some reason, your reply wasn’t appearing on my mobile.

    I’m using an Excerpt with a Word Count of 20. Displaying Read More as a Button. All so Displaying Tags.

    For Featured Images, I have those set to Display, with padding. Title is below the image and centered.

    Columns set to Display with 3 Columns. And Masonry.

    Thanks.

    #693789
    Tom
    Lead Developer
    Lead Developer

    Word count and read more button should happen by default. Doesn’t look like any of those posts are long enough for them to apply.

    The featured image settings should apply as well.

    Columns and masonry:

    add_filter( 'generate_blog_columns', 'tu_tax_columns' );
    function tu_tax_columns( $columns ) {
        if ( is_tax( 'sait_division' ) ) {
            return true;
        }
    
        return $columns;
    }
    
    add_filter( 'generate_blog_masonry', 'tu_tax_masonry' );
    function tu_tax_masonry( $masonry ) {
        if ( is_tax( 'sait_division' ) ) {
            return 'true';
        }
    
        return $masonry;
    }

    Tags and categories:

    add_action( 'generate_after_entry_title', 'tu_tax_meta' );
    function tu_tax_meta() {
        if ( is_tax( 'sait_division' ) ) : ?>
            <div class="entry-meta">
                <?php generate_posted_on(); ?>
            </div><!-- .entry-meta -->
        <?php endif;
    }

    Let me know if this gets us close ๐Ÿ™‚

    #693791
    David

    Hi Tom,

    Quick reply, Thanks!

    Now for the dumb question…where do I put the code? In the function.php or use elements-hook?

    I’m a design/implementer…I’m been using and recommending GeneratePress for several years, but I never had to add code to it until now.

    #693794
    Leo
    Staff
    Customer Support

    One of these methods here:
    Adding PHP: https://docs.generatepress.com/article/adding-php/

    #693799
    David

    Thanks, Leo.

    Perfect. I’ll try one of those tool in the morning. I actually read that page weeks ago, added the plugins in. Now I can actually use them.

    Again, many thanks to you and Tom.

    #693809
    Leo
    Staff
    Customer Support

    No problem!

    Let us know ๐Ÿ™‚

    #694162
    David

    Good morning,

    I was able to use the code for columns and masonry. It worked for a single taxonomy, but code snippet came back with the following error code when I tried to add another version with a different taxonomy…

    The code snippet you are trying to save produced a fatal error on line 8:

    Cannot redeclare tu_tax_columns() (previously declared in /homepages/14/d119673623/htdocs/learn/learn04/wp-content/plugins/code-snippets/php/snippet-ops.php(353) : eval()’d code:2)
    The previous version of the snippet is unchanged, and the rest of this site should be functioning normally as before.

    I have a total of four taxonomies and two post types: Course Topic, Resource Topic, Resource Type, SAIT-Divison, Course Type and Knowledge Resource Type.

    As for the tags and categories, the code did not work.

    Thanks

    #694487
    Tom
    Lead Developer
    Lead Developer

    Ah, you can add multiple taxonomies like this:

    add_filter( 'generate_blog_columns', 'tu_tax_columns' );
    function tu_tax_columns( $columns ) {
        if ( is_tax( array( 'sait_division', 'another_one', 'one_more' ) ) ) {
            return true;
        }
    
        return $columns;
    }
    
    add_filter( 'generate_blog_masonry', 'tu_tax_masonry' );
    function tu_tax_masonry( $masonry ) {
        if ( is_tax( array( 'sait_division', 'another_one', 'one_more' ) ) ) {
            return 'true';
        }
    
        return $masonry;
    }

    So just the two functions with the multiple taxonomies on the same line.

    As for the tags and categories – do your posts within these taxonomies have the core tags and categories enabled? Or are you using different taxonomies within them?

    #694496
    David

    The tags are core. I donโ€™t need to display categories.

    #694507
    Tom
    Lead Developer
    Lead Developer

    So instead of that tags/category function, try this:

    add_action( 'generate_after_entry_title', 'tu_tax_meta' );
    function tu_tax_meta() {
        if ( is_tax( array( 'sait_division', 'another_one', 'one_more' ) ) ) : ?>
            <div class="entry-meta">
                <?php
                    $tags_list = get_the_tag_list( '', ', ' );
                    if ( $tags_list ) {
                        echo $tags_list;
                    }
                ?>
            </div><!-- .entry-meta -->
        <?php endif;
    }

    get_the_tag_list() is a core WP functions, so it should work.

    #694525
    David

    Hi Tom,

    The first code work again. Thank you so very much.

    The tags code didn’t, so I decided to make a new taxonomy for subject tags. You’ve helped me to get where I needed to go.

    I can’t thank you guys enough.

    David

    #694616
    Tom
    Lead Developer
    Lead Developer

    Glad I could help! ๐Ÿ™‚

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