Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #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?

    #1291305

    Hey mosaic,

    Please post us your login credentials (in the “private data” field), so we can take a look at your backend.

    1. Install and activate ” Temporary Login Without Password “.
    2. Go to ” Users > Temporary Logins ” on the left-side menu.
    3. Click ” Create New “.
    4. 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 ).
    5. Click ” Submit “.
    6. 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,
    Nikko

    #1291353

    Link in private content. Thanks!

    #1291806

    Hi 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,
    Nikko

    #1292079

    Thanks, 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?

    #1292398

    Hi 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,
    Nikko

    #1293241

    Thank you!

    #1293301

    Hi mosaic,

    You’re welcome :)
    Thanks for using Enfold and have a great day!

    Best regards,
    Nikko

Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘'Do not allow duplicate posts on the entire page' not working’ is closed to new replies.