Display total number of attachments to a Post

<?php
global $post;
$attachments = get_children( array( 'post_parent' => $post->post_parent, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID' ) );

$count = count( $attachments );
$specific = array();
$i = 1;

foreach ( $attachments as $attachment ) {
    $specific[$attachment->ID] = $i;
    ++$i;
}

echo "Image {$specific[$post->ID]} of {$count}";

?>
Advertisements

Display External RSS Feeds in our Site

Here is the code for displaying External RSS Feeds in our Worpdress Site.

<?php include_once(ABSPATH.WPINC.'/feed.php');
$rss = fetch_feed('Feed URL Goes Here');
$maxitems = $rss->get_item_quantity(4);
$rss_items = $rss->get_items(0, $maxitems);
?>
<ul style="font-family:Helvetica;font-size:15px;list-style:square;">
<?php if ($maxitems == 0) echo '<li>No items.</li>';
else
// Loop through each feed item and display each item as a hyperlink.
foreach ( $rss_items as $item ) : ?>
<li>
<a href='<?php echo $item->get_permalink(); ?>'
title='<?php echo 'Posted '.$item->get_date('j F Y | g:i a'); ?>' target="_blank">
<?php echo $item->get_title(); ?></a>
</li>
<?php endforeach; ?>
</ul>

Keep Spreading…

Display WordPress comments in wordpress

I was trying to figure out, how i can display wordpress comment with a help of little coding..

<div class="post-recent-comment" style="font-size: 13px; font-weight: bold; font-family: Arial,helvetica;>

<?php


$comment_array = array_reverse(get_approved_comments($wp_query->post->ID));


$count = 1;


 ?>


<?php if ($comment_array) { ?>


<span class="comment"><?php comments_number('No comment','1 comment','% comments'); ?></span> – Latest by:


<ul class="commentlist"”>


<?php foreach($comment_array as $comment){ ?>


<?php if ($count++ <= 10) { ?>


<li><?php echo($comment->comment_author . '<br />' . $comment->comment_content); ?></li>


<?php } ?>


<?php } ?>


</ul>


<?php } else { ?>


<span class="comment">No comments so far</span>


<?php } ?>


</div>