• Resolved Lock-N-Load

    (@lock-n-load)


    So the original developer of the site created a plugin called “Tips” that is essentially a slider on our home page of the most current and recent 5 blog posts titles and links to them.

    However, I noticed that it is also showing posts that are set to Draft or Pending. So, the slider is showing these Draft posts whereas they are not even live and published on the blog yet. Eek!

    This “tips” plugin is only 1 page of php code, but I am not sure I know where the issue is or how to fix it to stop revealing Draft posts that are not live and not ready for primetime.

    Any help out there. The original developer has gone MIA.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter Lock-N-Load

    (@lock-n-load)

    Could it be something in this code bit:

    <?php
    $args = array( 'numberposts' => '5' );
    $recent_posts = wp_get_recent_posts( $args );
    $cnt = 0;
    foreach( $recent_posts as $recent )
    {
    echo '<a href="#" data-to="'.$cnt.'" >?</a>';
    $cnt++;
    }
    ?>

    or this?

    <?php
    									$args = array( 'numberposts' => '5' );
    									$recent_posts = wp_get_recent_posts( $args );
    									foreach( $recent_posts as $recent ){
    										echo'	<div class="item">
    													<h3>
    														<div class="tips-head">Tips:</div>
    														<a href="' . get_permalink($recent["ID"]) . '" title="Look '.esc_attr($recent["post_title"]).'" >' .   $recent["post_title"].'</a>
    													</h3>
    												</div>
    											';
    									}
    								?>

    Or is it something deeper in the theme that the plugin is tapping into to reveal these Draft posts publically?

    Thread Starter Lock-N-Load

    (@lock-n-load)

    Anyone have any ideas? I can provide the full “tips.php” file if needed.

    https://codex.www.ads-software.com/Function_Reference/wp_get_recent_posts

    the default uses any post status:

    'post_status' => 'draft, publish, future, pending, private',

    try and set it to just 'publish'; i.e.:

    $args = array( 'numberposts' => '5', 'post_status' => 'publish' );

    Thread Starter Lock-N-Load

    (@lock-n-load)

    You nailed it!!!

    I changed

    $args = array( ‘numberposts’ => ‘5’ );

    to be

    $args = array( ‘numberposts’ => ‘5’, ‘post_status’ => ‘publish’ );

    and no more issue. Thanks!

    is your site cached in any way?

    do other changes, like changing the number 5 to 3, take effect?

    Thread Starter Lock-N-Load

    (@lock-n-load)

    Nope. you nailed it…

    there are 2 references to

    $args = array( ‘numberposts’ => ‘5’ );

    I changed the first one and it did not work. I changed the second one and presto…

    Thanks for the solution, I will now know forever!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Custom plugin is revealing blog posts that are set as Draft or Pending’ is closed to new replies.