-
AuthorPosts
-
March 29, 2021 at 3:59 pm #1291109
I’m using the blog posts element to display more posts at the bottom of each post. I’ve selected the option ”Do not allow duplicate posts on the entire page’ but if you check the link in private content you can see that it shows the same post that is already open. Is there a way to get it to hide the post that the viewer is currently reading?
March 30, 2021 at 10:12 am #1291305Hey mosaic,
Please post us your login credentials (in the “private data” field), so we can take a look at your backend.
- Install and activate ” Temporary Login Without Password “.
- Go to ” Users > Temporary Logins ” on the left-side menu.
- Click ” Create New “.
- Add the email address for the account ( you can use (Email address hidden if logged out) ), as well as the ” Role ” making that the highest possible and the expiry about four days
( to be sure that we have enough time to debug ). - Click ” Submit “.
- You’ll now have a temporary account. Please provide us here in the private section the URL, so we can login and help you out.
When your issue is fixed, you can always remove the plugin!
If you prefer to not use the plugin, you can manually create an admin user and post the login credentials in the “private data” field.Best regards,
NikkoMarch 30, 2021 at 12:24 pm #1291353Link in private content. Thanks!
April 1, 2021 at 3:59 pm #1291806Hi mosaic,
Thanks for giving us admin access. I see you are putting it inside a post, unfortunately, Blog Posts’ offset only works with another Blog Post element or Magazine element, which is why it has this description.
The offset determines where the query begins pulling posts. Useful if you want to remove a certain number of posts because you already query them with another blog or magazine element.
To fix this I have added this code in functions.php:
function enfold_exclude_current_post($query) { if (is_single() && 'post' == get_post_type()) { $exclude = avia_get_the_ID(); $query->set( 'post__not_in', array($exclude) ); } } add_action('pre_get_posts', 'enfold_exclude_current_post');
however we do not recommend modifying the parent theme (enfold), so I just removing the code I added at the bottom of functions.php.
Then use a child theme, you can download and find instructions in this link: https://kriesi.at/documentation/enfold/child-theme/
Then copy the code and paste it on the child theme’s functions.php file.Best regards,
NikkoApril 3, 2021 at 11:26 am #1292079Thanks, are there any drawbacks to using a child theme? Will I be able to update as normal and experience the updates immediately whilst retaining modifications I’ve made to functions.php?
April 5, 2021 at 3:32 am #1292398Hi mosaic,
The drawbacks in using a child theme are modified files get outdated (since it is overridden) and you might need to check if there are changes for that file but I think it is better than modifying it in the parent theme which modifications are lost during the theme update and you’ll need to re-apply it.
In this case we are using a hook, so there should be no drawback unless WordPress decides to deprecate pre_get_posts hook.
Here’s an article which discusses pros and cons of a child theme: https://www.wpbeginner.com/beginners-guide/wordpress-child-theme-pros-cons/
Hope this helps.Best regards,
NikkoApril 8, 2021 at 11:48 am #1293241Thank you!
April 8, 2021 at 3:56 pm #1293301Hi mosaic,
You’re welcome :)
Thanks for using Enfold and have a great day!Best regards,
Nikko -
AuthorPosts
- The topic ‘'Do not allow duplicate posts on the entire page' not working’ is closed to new replies.