- This topic has 36 replies, 4 voices, and was last updated 4 years, 1 month ago by
David.
-
AuthorPosts
-
August 18, 2021 at 3:20 pm #1900674
nomadiceman
I’ve replaced Elvins code with David’s.
The pages 2 onwards of that tag archive still show the element
I wonder what I’m doing wrong
Any help is greatly appreciated
August 18, 2021 at 3:57 pm #1900693nomadiceman
to confirm yes its a block element
The Block Element has these settings:
Block – Hook
generate_before_main_contentlocation: Post Tag Archive: Visa
hope that helps
August 18, 2021 at 4:34 pm #1900711David
StaffCustomer SupportI made a slight mistake in my code. I have updated it here:
Make sure to update the ID.
August 18, 2021 at 4:39 pm #1900714nomadiceman
perfect it worked! thanks David.
I honestly have no idea how you guys handle looking at code all day. it fries my brain
thank you for you continued help
August 18, 2021 at 4:40 pm #1900716David
StaffCustomer SupportWe start the day with fried brains lol
Glad to be of help!
August 18, 2021 at 4:41 pm #1900717nomadiceman
hahaha
August 20, 2021 at 6:03 am #1902404nomadiceman
Hi elvin,
ive just noticed that the code to remove posts that are already shown by WPSP isn’t working.
as you can see in the link ive sent
the code from that link you supplied which was written by Tom is this:
// Track IDs added by WPSP. add_action( 'wpsp_before_header', function() { global $displayed_posts; $displayed_posts[] = get_the_ID(); } ); // Don't output posts already being output. add_filter( 'generate_do_template_part', function( $do ) { global $displayed_posts; if ( in_array( get_the_ID(), (array) $displayed_posts )) { $do = false; } return $do; } );
any idea how to make this work as needed?
I see that 2 of the WPSP posts are not displayed, but 1 is. I’ve also noticed that maybe its because one of the WPSP position in the normal archive is on page 2. I hope that makes sense
thanks for you help guys
August 20, 2021 at 11:04 am #1902879David
StaffCustomer SupportDo you have any Page Caching either plugin or server side ?
If so try clearing the caches.August 20, 2021 at 3:23 pm #1903043nomadiceman
Hi David. I’ve just double checked all chaching and it’s still showing
Hope you guys can figure it out 🙏
August 21, 2021 at 4:33 am #1903416David
StaffCustomer SupportNot sure but lets try adding the global variable earlier in the code.
Keep your existing code, but add this snippet before it:add_action('init', function(){ global $displayed_posts; $displayed_posts = ''; },100);
As an aside, how are the Featured Posts selected for that archive ? I assume its not the Latest Posts ?
August 21, 2021 at 4:52 am #1903427nomadiceman
To select the 3 posts I want at the top I just add the page reference number in wpsp. Hope that’s correct.
I’ll try that vide asap
August 21, 2021 at 5:58 am #1903480David
StaffCustomer SupportLet us know how that snippet works.
August 21, 2021 at 1:58 pm #1903934nomadiceman
Hi, sorry David. I’m a little confused.
Where do I put that code?
August 21, 2021 at 2:49 pm #1903953nomadiceman
if you mean this, I added it and the site broke
add_action('init', function(){ global $displayed_posts; $displayed_posts = ''; },100); add_filter( 'generate_element_display', function( $display, $element_id ) { if ( 13152 === $element_id && is_paged() ) { $display = false; } return $display; }, 10, 2 );
August 21, 2021 at 5:20 pm #1904006David
StaffCustomer SupportRemove the snippet for the time being.
I’ll relook at the options. -
AuthorPosts
- You must be logged in to reply to this topic.