WordPress.org

Ready to get started?Download WordPress

Forums

Top 10 - Popular posts plugin for WordPress
[resolved] Exclude current post/displaying post? (12 posts)

  1. Newfound
    Member
    Posted 6 months ago #

    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/

  2. Ajay
    Member
    Plugin Author

    Posted 6 months ago #

    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 :)

  3. Newfound
    Member
    Posted 6 months ago #

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

  4. Ajay
    Member
    Plugin Author

    Posted 6 months ago #

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

  5. Newfound
    Member
    Posted 6 months ago #

    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. :(

  6. Ajay
    Member
    Plugin Author

    Posted 6 months ago #

    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 );
    
    ?>
  7. Newfound
    Member
    Posted 6 months ago #

    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!

  8. Ajay
    Member
    Plugin Author

    Posted 6 months ago #

    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.

  9. Newfound
    Member
    Posted 6 months ago #

    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!

  10. Ajay
    Member
    Plugin Author

    Posted 6 months ago #

    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 );
  11. Newfound
    Member
    Posted 5 months ago #

    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! :)

  12. Ajay
    Member
    Plugin Author

    Posted 5 months ago #

    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?

Reply

You must log in to post.

About this Plugin

About this Topic