- This topic has 13 replies, 4 voices, and was last updated 3 years ago by David.
-
AuthorPosts
-
October 27, 2020 at 1:58 am #1505817Alessandro
Hi, I inserted an intro text on the home page, but I would like it not to be repeated in the pagination pages /page/2/ /page/3/ …
How can I do?
October 27, 2020 at 4:30 am #1505979DavidStaffCustomer SupportHi there,
you can add this PHP Snippet to exclude a specific Block Element when visiting a paged instance:
add_filter( 'generate_block_element_display', function( $display ) { if ( 123 === $element_id && is_paged() ) { $display = false; } return $display; } );
The
123
has to be replaced with the Block Elements ID – you can get this by editing the Block element and checking the URL in the browser.October 27, 2020 at 6:24 am #1506109AlessandroThanks David, but the modify don’t show.
I use a child theme, but strangely, the css and the function.php changes are not read either.
Currently in the child there is this content:<?php /** * GeneratePress child theme functions and definitions. * * Add your custom PHP in this file. * Only edit this file if you have direct access to it on your server (to fix errors if they happen). */ function generatepress_child_enqueue_scripts() { if ( is_rtl() ) { wp_enqueue_style( 'generatepress-rtl', trailingslashit( get_template_directory_uri() ) . 'rtl.css' ); } } add_action( 'wp_enqueue_scripts', 'generatepress_child_enqueue_scripts', 100 ); add_filter( 'generate_google_font_display', function() { return 'swap'; } ); function no_self_ping( &$links ) { $home = get_option( 'home' ); foreach ( $links as $l => $link ) if ( 0 === strpos( $link, $home ) ) unset($links[$l]); } add_action( 'pre_ping', 'no_self_ping' ); add_filter( 'generate_block_element_display', function( $display ) { if ( 434 === $element_id && is_paged() ) { $display = false; } return $display; } );
October 27, 2020 at 11:15 am #1506820LeoStaffCustomer SupportCan you clear and disable your caching plugin first?
October 28, 2020 at 7:50 am #1508024Alessandroplugin disabled and cache deleted.
Unfortunately the problem persists.October 28, 2020 at 8:35 am #1508107DavidStaffCustomer SupportCan you try moving the function i provided to the just below this function:
function generatepress_child_enqueue_scripts() { if ( is_rtl() ) { wp_enqueue_style( 'generatepress-rtl', trailingslashit( get_template_directory_uri() ) . 'rtl.css' ); } } add_action( 'wp_enqueue_scripts', 'generatepress_child_enqueue_scripts', 100 );
October 28, 2020 at 9:03 am #1508154AlessandroDone, no change.
If it helps, I’ll send you access to WP in tried.October 28, 2020 at 2:02 pm #1508532TomLead DeveloperLead DeveloperHi there,
Try this, instead:
add_filter( 'generate_block_element_display', function( $display, $element_id ) { if ( 123 === $element_id && is_paged() ) { $display = false; } return $display; }, 10, 2 );
October 29, 2020 at 7:36 am #1509266AlessandroThanks Tom, now it works ๐
October 29, 2020 at 10:02 am #1509896TomLead DeveloperLead DeveloperYou’re welcome ๐
March 28, 2021 at 2:02 am #1712634AlessandroHi,
i have the same problem on another website.
I have test the first and second code, but don’t work. It’s an “Header” type.
How can i do?March 28, 2021 at 4:00 am #1712707DavidStaffCustomer SupportHi there,
you would use the
generate_header_element_display
filter:https://docs.generatepress.com/article/generate_header_element_display/
So in Tom’s example you would do:
add_filter( 'generate_header_element_display', function( $display, $element_id ) { if ( 123 === $element_id && is_paged() ) { $display = false; } return $display; }, 10, 2 );
March 29, 2021 at 12:01 am #1713589Alessandrothank you David!
Work perfectly.
Have a nice day
AlessandroMarch 29, 2021 at 3:52 am #1713764DavidStaffCustomer Supportyou’re welcome
-
AuthorPosts
- You must be logged in to reply to this topic.