-
formanite22
Hi,
I created a container (that starts with the text: YOU MY ALSO LIKE) at the bottom of a page, on preview, the content inside the container is appearing above the page navigation. I wanted to make it appear below the page navigation.
Afterwards, I tried using the Block-Hook element. The content of the container did appear below the page navigation. However, there is an issue. The page is divided using a Page Break into 5 pages. The Block element is appearing after every page (Page 1-5), instead, of only appearing after the last page (Page 5). I have used after_content option in the Hook Name.What is the solution for both the cases?
Thanks! -
Hi there,
Try this PHP filter, replace the
100
with your element id which can be found in the URL of the element editor:add_filter( 'generate_element_display', function( $display, $element_id ) { global $wp_query; if ( 100 === $element_id && !( is_paged() && $wp_query->max_num_pages === get_query_var( 'paged' ) ) ) { $display = false; } return $display; }, 10, 2 );
Let me know if this helps!
-
formanite22
Hi,
I added the PHP code using the Code Snippets plugin following this document (https://docs.generatepress.com/article/adding-php/).
Then replaced the100
with the element id14541
present in the URL of the element editor.
The code did not work.
The block element disappeared from all the pages (Page 1-5). -
David
Hi there,
try this instead:
add_filter( 'generate_element_display', function( $display, $element_id ) { if ( 14541 === $element_id && is_paged() ) { $display = false; } return $display; }, 10, 2 );
-
formanite22
Hi there,
This does not work either.
The block element is still appearing on all the pages (Page 1-5). -
David
Can you double check the Element ID is correct ?
-
formanite22
Upon editing the Element, I have mentioned the URL of the Element in the Private Information.
Just to confirm, is the this Element ID14541
? -
David
Yeah that is the ID.
So lets give this a shot instead:
add_filter( 'generate_element_display', function( $display, $element_id ) { $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; if ( 14541 === $element_id && 1 != $paged ) { $display = false; } return $display; }, 10, 2 );
-
formanite22
Hi there,
I tried it. It did not work.
The block element is still appearing on all the pages (Page 1-5). -
David
Can i get an Admin login to the site so i can take a closer look ?
-
formanite22
Yes,
I can provide Admin login using Temporary Login Without Password plugin.
For this, can you provide me an email address to setup the temporary login? -
David
Can you create an account with a fictional email / username. As we don’t need the email access options.
-
formanite22
Oh Right.
I didn’t know that.
I have entered the Admin access link in the Private Information. -
Fernando
Hello Formanite,
Can you try this snippet?:
add_filter( 'generate_block_element_display', function( $display, $element_id ) { global $wp_query; if ( 14541 === $element_id && !( is_paged() && $wp_query->max_num_pages === get_query_var( 'paged' ) ) ) { $display = false; } return $display; }, 10, 2 );
Let us know how it goes.
-
formanite22
Hi there,
It did not work. The block element disappeared from all the pages (Page 1-5). -
The PHP method doesn’t work might because it’s not wp default pagination but added by a plugin.
In that case, you might need to contact the plugin support for how to target the paged page.
Or we can try a CSS solution, if you are ok with CSS, please activate the element for us to write the CSS.
Let me know 🙂
- You must be logged in to reply to this topic.