Skip to content

Instantly share code, notes, and snippets.

@macdawne
Last active July 10, 2017 20:20
Show Gist options
  • Save macdawne/7a2ed47c6927bf49d2591e9313e091dc to your computer and use it in GitHub Desktop.
Save macdawne/7a2ed47c6927bf49d2591e9313e091dc to your computer and use it in GitHub Desktop.
Show-Count-Post-Wp.php
<?php
$allpoststype = new WP_Query(array( 'post_type'));
if ($allpoststype->have_posts()) :
$count_posts = wp_count_posts()->publish;
if ( $count_posts == "1" ) :
echo "<center>
<button type='button' class='btn btn-success'>Notification
<span class='badge'>01</span></button> </center>"; ?>
<?php else :
echo "<center>
<button type='button' class='btn btn-danger'>Notification
<span class='badge'> $count_posts </span></button> </center>";
endif;?>
<?php else : ?>
<center>
<button type='button' class='btn btn-info'>Notification
<span class='badge'>00</span></button> </center>
<?php endif;?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment