Tagged: function.php
-
AuthorPosts
-
May 24, 2021 at 12:55 pm #1301991
Hi, Enfolders
I would like to remove div class [div class=’page-summary’/> from a pagination pages. If visitors on /page/2/ the desire div class should be removed. It should be done with php not not with css.
Example: check below example
screenshot: https://prnt.sc/13cezf0
pagination: https://copybloggerthemes.com/blogger-templates/responsive/page/2/To give an idea something code like should be in function.php
$paged = $wp_query->get( 'paged' ); if ( $paged < 2 ) { // do nothing return; } else { // remove div 'page-summary' from /page/2/ and /page/3/ so on remove'<div class='page-summary'/>; }
I am using Enfold since 2015, it is a great theme and support team always helped me a lot.
waiting to see the response soon.May 26, 2021 at 7:06 am #1302364Hey Hafeez Ullah,
Thank you for the inquiry.
Those container are not generated by the theme, or do not exist in any of the theme template files. Did you create a custom template file? We can remove the container with a simple script if you like.
Something like this.
var summary = document.querySelector(".page-summary"); summary.remove();
You can use the wp_footer hook to append it to the page or to the document, or use the wp_add_inline_script function.
// https://developer.wordpress.org/reference/functions/wp_add_inline_script/
Best regards,
IsmaelMay 27, 2021 at 12:50 am #1302474Yes, i am using the <class=’page-summary’/> as the custom tag inside the pages.
Your code work but it remove the class from every page, while i want to apply certain condition that the code should only remove the <class=’page-summary’/> from /page/2/ pagination and so on. Like i have given example above.I hope you will help me there. Thanks bundles
May 31, 2021 at 5:23 am #1303058Hi,
while i want to apply certain condition that the code should only
Sorry for the delay. Try to check if the body tag contains a certain class name. Example.
var body = document.querySelector("body"); // check if the body tag has the class name page-id-321 or if the current page has the ID 321 var is_page_321 = body.classlist.contains("page-id-321"); if(is_page_321) { // do something here // like removing the page-summary container }
Best regards,
IsmaelSeptember 19, 2021 at 10:08 pm #1321550Hi, I’m after a similar solution. I only want to display the header in the 1st page of the pagination of a blog, and remove it in the following pages.
I can’t find a way to remove it. Should I go through CSS or functions.php?
Many thanks! :)
September 20, 2021 at 8:37 am #1321579 -
AuthorPosts
- You must be logged in to reply to this topic.