[Resolved] Category description below category posts

Home Forums Support [Resolved] Category description below category posts

Home Forums Support Category description below category posts

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #840192
    ETO

    Hello,
    In the category pages, there appears first the description of the category and then the links of the post in that category. However, I want the description to appear below the post links. Could you help me with this, please?

    #840241
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    As of right now, the description is hard-coded into the same function that displays the title. This means we can only move it if we move the title as well.

    In GP 2.3, we’ll be hooking the description into the title function, which means we’ll be able to move the description elsewhere easily.

    I suppose we could completely remove the element added by GP and add our own custom title and description? Would that work for you?

    Let me know 🙂

    #840405
    ETO

    I see. As there are tens of categories, it will be lots of work to remove and add custom titles and descriptions. So I would like to wait for GP 2.3 release.

    #840782
    Tom
    Lead Developer
    Lead Developer

    You wouldn’t need to manually do anything to your categories.

    You could just do this:

    add_action( 'wp', function() {
        if ( is_category() ) {
            remove_action( 'generate_archive_title', 'generate_archive_title' );
            add_action( 'generate_archive_title', 'tu_custom_archive_title' );
            add_action( 'generate_after_main_content', 'tu_custom_archive_description' );
        }
    } );
    
    function tu_custom_archive_title() {
        ?>
            <div class="page-header">
                <h1 class="page-title">
                    <?php the_archive_title(); ?>
                </h1>
            </div>
        <?php
    }
    
    function tu_custom_archive_description() {
        $term_description = term_description();
    
        if ( ! empty( $term_description ) ) {
            printf( '<div class="taxonomy-description">%s</div>', $term_description ); // WPCS: XSS ok, sanitization ok.
        }
    }
    #841641
    ETO

    Thanks. But when I use the code above the code here does not work.

    #841722
    Tom
    Lead Developer
    Lead Developer

    I’m not sure I understand. How are you implementing that code?

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