- This topic has 44 replies, 3 voices, and was last updated 2 years, 6 months ago by
Tom.
-
AuthorPosts
-
September 11, 2019 at 12:05 pm #1007094
Sonja
Hello,
On a category page, there are teasers of the posts. Now I want content below these teasers, but only on first page and not on page 2,3,4,etc.
How can I achieve this?
September 11, 2019 at 12:14 pm #1007100Leo
StaffCustomer SupportHi there,
If I understand this correctly, you can likely achieve this with a Hook Element:
https://docs.generatepress.com/article/hooks-element-overview/With the filter to display it:
https://docs.generatepress.com/article/generate_hook_element_display/And the conditional tag would be this one:
https://codex.wordpress.org/Conditional_Tags#A_Paged_PageIf you search keyword
is_paged
in our forum to see some examples.Let me know if this helps 🙂
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/September 11, 2019 at 12:36 pm #1007111Sonja
Hmm, okay, I understand, that i can use the generate_after_main_content hook. But how can I achieve, that this would be show only on first page of a specific category page?
September 11, 2019 at 1:28 pm #1007145Leo
StaffCustomer SupportYou can use the filter as I mentioned above.
The code should be something like this:
add_filter( 'generate_hook_element_display', function( $display ) { if ( 10 === $element_id && is_paged() ) { $display = false; } return $display; } );
Make sure to replace
10
with the actual element ID.Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/September 11, 2019 at 1:36 pm #1007148Sonja
okay, that is too complicated for me. I don´t understand this. I think such thinks should be easier to do and not only available for coders.
September 11, 2019 at 3:33 pm #1007200Leo
StaffCustomer SupportHave you tried the code above?
The only part you need to change the element ID.
Sometimes a little bit of code is required for specific display rules you are asking, which is why we are always available to help.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/September 12, 2019 at 3:42 am #1007483Sonja
I have create a after_main_content hook withthe display rules, that it shows only on this category archive.
Then I have create the filter you postet and set the elemt ID of the hook.
But the content (at the moment the word “test” shows also on page 2 of the archive.
And also I want that the content should in a box like the other contetn on this site and have the same spacing like the other boxes.
I have add the URL in the above post.
September 12, 2019 at 4:27 am #1007517David
StaffCustomer SupportHi there,
did you remove the hook and the filter? currently i cannot see the ‘test’ content on any of those pages. If you have, can you re-add them and let us know.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/September 12, 2019 at 4:32 am #1007518Sonja
Hi David,
no it is still there on the URL i postet. You can see the word “test” below the pagination.
September 12, 2019 at 4:33 am #1007523David
StaffCustomer SupportCan you flush and disable your cache as i am not seeing the content.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/September 12, 2019 at 4:36 am #1007527Sonja
Okay, done.
September 12, 2019 at 4:52 am #1007534David
StaffCustomer SupportNow i can see it on page 1 only. So it seems to be working.
I can still see the cache enabled which is making it tricky to style the element. Can you make sure all your cache plugins are disabled?Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/September 12, 2019 at 5:02 am #1007544Sonja
I can see it on both pages. With different Browsers.
I use WP-Rocket. Is it possible to deactivate the plugin and activate again without any problems? Or do i have to do soemthing special after activate ist again?
September 12, 2019 at 5:18 am #1007552David
StaffCustomer SupportYou can flush/purge/clear ( or whatever they call it ) first then disable it, then when were done you can re-enable it.
You may also need to flush your browser caches after disabling the plugin. Best to view the site in an Incognito/Private browser to test if its also a browser caching issue.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/September 12, 2019 at 5:27 am #1007558Sonja
OK I have deactivate it. But I see the test still on both pages.
-
AuthorPosts
- You must be logged in to reply to this topic.