- This topic has 19 replies, 4 voices, and was last updated 1 year, 11 months ago by Fernando.
-
AuthorPosts
-
July 4, 2019 at 11:35 pm #949514Silko
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
July 5, 2019 at 8:22 am #949883TomLead DeveloperLead DeveloperHi 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' ); } } );
July 5, 2019 at 9:50 am #949957SilkoHi 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?
July 5, 2019 at 10:03 am #949967LeoStaffCustomer SupportI’m looking at this page: https://www.notargebuehren.com/notar-berlin/
And only see the description at the bottom?
Am I missing something?
July 16, 2019 at 7:18 am #959138SilkoHi 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!
July 16, 2019 at 9:23 am #959404LeoStaffCustomer SupportI tested the code and it worked perfectly for me.
Can you try clearing and disabling Cachify and Autoptimize first?
July 28, 2019 at 10:25 am #969447SilkoHi 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?
July 28, 2019 at 7:02 pm #969654TomLead DeveloperLead DeveloperHi 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
July 28, 2019 at 9:11 pm #969690SilkoHi 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>'; } } ?>
July 29, 2019 at 8:37 am #970228TomLead DeveloperLead DeveloperThis function is the issue:
generate_archive_title()
What is it doing, exactly?
July 29, 2019 at 10:38 pm #970725SilkoI 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”.
July 30, 2019 at 8:29 am #971197TomLead DeveloperLead DeveloperIf you remove that function, does it fix the issue?
July 31, 2019 at 12:56 am #971811SilkoIt works!
Thank you @ all.
July 31, 2019 at 8:55 am #972291TomLead DeveloperLead DeveloperYou’re welcome 🙂
September 24, 2021 at 1:45 am #1941205John MauiHi,
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' ); } } );
-
AuthorPosts
- You must be logged in to reply to this topic.