[Resolved] Moving the category description to the bottom

Home Forums Support [Resolved] Moving the category description to the bottom

Home Forums Support Moving the category description to the bottom

Viewing 15 posts - 1 through 15 (of 20 total)
  • Author
    Posts
  • #949514
    Silko

    Hi there,

    I am using the categories for a small directory like you can see here: https://www.notargebuehren.com/notar-berlin/

    I am using the child theme. How can I move the category description to the bottom? I want that the user first see the posts in the category and after that the category description.

    Thanks a lot in advance!

    Best regards,

    Silko

    #949883
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    Try this PHP:

    add_action( 'wp', function() {
        remove_action( 'generate_after_archive_title', 'generate_do_archive_description' );
    
        if ( is_archive() ) {
            add_action( 'generate_after_main_content', 'generate_do_archive_description' );
        }
    } );
    #949957
    Silko

    Hi Tom,

    thank you! It works so far. The problem now is that the category description is twice on the page (duplicate: top and bottom). How can I remove it from the top?

    #949967
    Leo
    Staff
    Customer Support

    I’m looking at this page: https://www.notargebuehren.com/notar-berlin/

    And only see the description at the bottom?

    Am I missing something?

    #959138
    Silko

    Hi Leo,

    please reload the page and have a look.

    Thank you. This is the function:

    add_action( ‘wp’, function() {
    remove_action( ‘generate_after_archive_title’, ‘generate_do_archive_description’ );

    if ( is_archive() ) {
    add_action( ‘generate_after_main_content’, ‘generate_do_archive_description’ );
    }
    } );

    Thank you!

    #959404
    Leo
    Staff
    Customer Support

    I tested the code and it worked perfectly for me.

    Can you try clearing and disabling Cachify and Autoptimize first?

    #969447
    Silko

    Hi Leo,

    I cleared the cache of the autoptimize and cachify theme. I also deactivated them. The category description is still displayed on top and the bottom.

    Do you want to have a look into the backend?

    #969654
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    Do you have any other functions on the site?

    If you’d like, you can send temporary admin login details and we’ll take a closer look: https://generatepress.com/contact

    #969690
    Silko

    Hi Tom,

    this is my function.php:

    <?php
    /**
     * GeneratePress functions and definitions
     *
     * @package GeneratePress
     */
    	
    function theme_enqueue_styles() {
    
    	$parent_style = 'generatepress-style';
    
    	wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
    	wp_enqueue_style( 'generatepress-child-style',
    	get_stylesheet_directory_uri() . '/style.css',
    	array( $parent_style )
    	);
    }
    add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
    
    add_action( 'wp', function() {
        remove_action( 'generate_after_archive_title', 'generate_do_archive_description' );
    
        if ( is_archive() ) {
            add_action( 'generate_after_main_content', 'generate_do_archive_description' );
        }
    } );
    
    /**
     * Build the archive title
    *
    * @since 1.3.24
    */
    add_action( 'generate_archive_title','generate_archive_title' );
    function generate_archive_title()
    {
    	?>
    	<header class="page-header<?php if ( is_author() ) echo ' clearfix';?>">
    		<?php do_action( 'generate_before_archive_title' ); ?>
    		<h1 class="page-title">
    			<?php
    				if ( is_category() ) :
    					echo "Notar ";
    					single_cat_title();
    
    				elseif ( is_tag() ) :
    					single_tag_title();
    
    				elseif ( is_author() ) :
    					/* Queue the first post, that way we know
    					 * what author we're dealing with (if that is the case).
    					*/
    					the_post();
    					echo get_avatar( get_the_author_meta( 'ID' ), 75 );
    					printf( '<span class="vcard">' . get_the_author() . '</span>' );
    					/* Since we called the_post() above, we need to
    					 * rewind the loop back to the beginning that way
    					 * we can run the loop properly, in full.
    					 */
    					rewind_posts();
    
    				elseif ( is_day() ) :
    					printf( __( 'Day: %s', 'generatepress' ), '<span>' . get_the_date() . '</span>' );
    
    				elseif ( is_month() ) :
    					printf( __( 'Month: %s', 'generatepress' ), '<span>' . get_the_date( 'F Y' ) . '</span>' );
    
    				elseif ( is_year() ) :
    					printf( __( 'Year: %s', 'generatepress' ), '<span>' . get_the_date( 'Y' ) . '</span>' );
    
    				elseif ( is_tax( 'post_format', 'post-format-aside' ) ) :
    					_e( 'Asides', 'generatepress' );
    
    				elseif ( is_tax( 'post_format', 'post-format-image' ) ) :
    					_e( 'Images', 'generatepress');
    
    				elseif ( is_tax( 'post_format', 'post-format-video' ) ) :
    					_e( 'Videos', 'generatepress' );
    
    				elseif ( is_tax( 'post_format', 'post-format-quote' ) ) :
    					_e( 'Quotes', 'generatepress' );
    
    				elseif ( is_tax( 'post_format', 'post-format-link' ) ) :
    					_e( 'Links', 'generatepress' );
    
    				else :
    					_e( 'Archives', 'generatepress' );
    
    				endif;
    			?>
    		</h1>
    		<?php do_action( 'generate_after_archive_title' ); ?>
    		<?php
    			// Show an optional term description.
    			$term_description = term_description();
    			if ( ! empty( $term_description ) ) :
    				printf( '<div class="taxonomy-description">%s</div>', $term_description );
    			endif;
    			
    			if ( get_the_author_meta('description') && is_author() ) : // If a user has filled out their decscription show a bio on their entries
    				echo '<div class="author-info">' . get_the_author_meta('description') . '</div>';
    			endif;
    		?>
    		<?php do_action( 'generate_after_archive_description' ); ?>
    	</header><!-- .page-header -->
    	<?php
    }
    
    function generate_entry_meta()
    {
    	$categories = apply_filters( 'generate_show_categories', true );
    	$tags = apply_filters( 'generate_show_tags', true );
    	$comments = apply_filters( 'generate_show_comments', true );
    
    	if ( 'post' == get_post_type() ) {
    
    		$categories_list = get_the_category_list( _x( ', ', 'Used between list items, there is a space after the comma.', 'generatepress' ) );
    		if ( $categories_list && $categories ) {
    			printf( '<span class="cat-links"><span class="screen-reader-text">%1$s </span>%2$s</span>',
    			_x( 'Categories', 'Used before category names.', 'generatepress' ),
    			$categories_list
    			);
    		}
    
    		$tags_list = get_the_tag_list( '', _x( ', ', 'Used between list items, there is a space after the comma.', 'generatepress' ) );
    		if ( $tags_list && $tags ) {
    			printf( '<span class="tags-links"><span class="screen-reader-text">%1$s </span>%2$s</span>',
    			_x( 'Tags', 'Used before tag names.', 'generatepress' ),
    			$tags_list
    			);
    		}
    	}
    
    	if ( ! is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) && $comments ) {
    		echo '<span class="comments-link">';
    		comments_popup_link( __( 'Notar kontaktieren', 'generatepress' ), __( '1 Comment', 'generatepress' ), __( '% Comments', 'generatepress' ) );
    		echo '</span>';
    	}
    }
    
    ?>
    #970228
    Tom
    Lead Developer
    Lead Developer

    This function is the issue: generate_archive_title()

    What is it doing, exactly?

    #970725
    Silko

    I have no idea to be honest.

    Edit: I guess it adds the word “Notar” in front of the category title. So at the end the archive title will be for example “Notary Washington”.

    #971197
    Tom
    Lead Developer
    Lead Developer

    If you remove that function, does it fix the issue?

    #971811
    Silko

    It works!

    Thank you @ all.

    #972291
    Tom
    Lead Developer
    Lead Developer

    You’re welcome 🙂

    #1941205
    John Maui

    Hi,

    I try to use it but the description is shown also in top & bottom. Pls see it in https://www.wildboarcoffee.com/espresso-machines/delonghi/

    I used child theme also. I did clear all cache (used Litespeed) but it don’t work. Code in the functions.php is

    add_action( 'wp', function() {if ( is_single() ) {add_filter( 'generate_show_post_navigation', '__return_false' );}} );
    add_action( 'wp', function() {
    remove_action( 'generate_after_archive_title', 'generate_do_archive_description' );
    
    if ( is_archive() ) {
    add_action( 'generate_after_main_content', 'generate_do_archive_description' );
    }
    } );
Viewing 15 posts - 1 through 15 (of 20 total)
  • You must be logged in to reply to this topic.