WordPress.org

Support

Support » Plugins and Hacks » [Resolved] Exclude current post/displaying post?

[Resolved] Exclude current post/displaying post?

  • Newfound

    @precipitatejournal

    Hi there!

    I am interested in using your plugin at the bottom of the front page of my blog (www.hothousemagazine.org), which already displays the single most current post. My hope is to have my main blog page to show the current post and then (using your plugin) show visitors the top posts for the current week.

    However, I’m wondering if there is a way to exclude the most recent post so that it doesn’t come up in the weekly count and show twice with this setup. Does this make any sense?

    Your plugin looks great, btw!

    Cheers!

    http://wordpress.org/plugins/top-10/

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author Ajay

    @ajay

    You can try the manual install in the FAQ
    https://wordpress.org/plugins/top-10/faq/

    Regarding excluding the most recent post, I think there might be a solution you can try, but it isn’t tested and I’m not sure if this will work, so please backup before editing files.

    $args = array( 'numberposts' => '1' );
    $recent_posts = wp_get_recent_posts( $args );
    
    foreach( $recent_posts as $recent ){
    $exclude_post_ids = $recent["ID"];
    }
    
    echo tptn_pop_posts( 'daily=1&is_widget=1&exclude_post_ids='.$exclude_post_ids );

    Thanks for the compliment about my plugin. Do consider leaving a good review 🙂

    Newfound

    @precipitatejournal

    Great! And where would I paste this code? On the same page that I paste in the manual install code?

    Plugin Author Ajay

    @ajay

    Yes, in the footer maybe. Wherever you want the code to display

    Newfound

    @precipitatejournal

    I pasted it in the loop.php. The manual code is displaying just fine but this extra code (just pasted it beneath) just displays as text. Do I need to put the code in <? ?> brackets? I’m not a php wizard, sadly. 🙁

    Plugin Author Ajay

    @ajay

    Sorry, yes, you’ll need to wrap it in php tags. Are you sure loop.php is the right place? It’s dependent from theme to theme, but ideally you’ll need to put this outside the Loop part of loop.php

    <?php
    $args = array( 'numberposts' => '1' );
    $recent_posts = wp_get_recent_posts( $args );
    
    foreach( $recent_posts as $recent ){
    $exclude_post_ids = $recent["ID"];
    }
    
    echo tptn_pop_posts( 'daily=1&is_widget=1&exclude_post_ids='.$exclude_post_ids );
    
    ?>
    Newfound

    @precipitatejournal

    Well, I have things in the loop.php so they show on my main blog landing page thing, which shows the most recent blog. Maybe I should have said that before framing my initial question.

    Okay, here’s maybe another way of looking at this problem: If I’m putting your sweet plugin in the loop, which will always show the most recent post, is there simply a way for the plugin to show my daily posts except for the most recent??

    Thanks for your time and patience!

    Plugin Author Ajay

    @ajay

    The code above should ideally do that. Did you have a chance to look at it.

    I’ve tried to fetch the latest post and then feed it as an exclusion. I can’t confirm if this is going to work 100% for sure.

    Newfound

    @precipitatejournal

    Okay, I’ve posted in the code and the plugin is showing properly (although the daily posts title doesn’t show now, but that’s no big deal).

    I can’t tell right now, however, if the code is working, as my top three posts are not the most current post. I will be sure to get back to you if it doesn’t accomplish this feat, just to let you know at least.

    Cheers!

    Plugin Author Ajay

    @ajay

    That sounds great. If you want the header to come back edit to code above. Change this line:

    echo tptn_pop_posts( 'daily=1&is_widget=0&exclude_post_ids='.$exclude_post_ids );
    Newfound

    @precipitatejournal

    Aww, well, sadly it doesn’t seem to be working: http://www.hothousemagazine.org/, only looked as if it was working because the “most recent” needs time to catch up to be on my top 3 list.

    If you come up with any other ideas, do shoot them this way. Integrating this in with a future release would be killer! 🙂

    Plugin Author Ajay

    @ajay

    So, if I understand correctly, if your most recent catches up to be on the top 3, it shows up in the Week’s Hottest?

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘[Resolved] Exclude current post/displaying post?’ is closed to new replies.