0

I'm using this plugin called "Quicksand" for Wordpress.. You might wanna check the link.

What it does normally is it filters posts based on the category..

It shows the

  1. Featured Image
  2. Title of the Post

I want to add an excerpt below the Title of the posts.. I opened the quicksand_fucntion.php

I tried to add it but i think im missing something...

Here's the PHP code

    <ul class="ourHolder">
    <?php                                                     
    $args = array(
    'posts_per_page' => '-1',
    'post_type' => 'post',
    'post_status' => 'publish',
    'category__in' => $quicksand_categories 
    );
    $query = new WP_Query( $args );
    foreach ($query->posts as $item) {
    $categories = wp_get_post_categories($item->ID);
     ?>
    <li id="item" class="item" data-id="id-<?php echo $item->ID ?>" data-type="<?php foreach ($categories as $c) { echo $c . ' ';}?>" >
    <?php  if (get_option('featured') == 'yes') { ?>
    <a href="<?php echo get_permalink($item->ID); ?>">
    <?php  echo get_the_post_thumbnail($item->ID,array(100,100));  ?>
    </a>
    <?php } ?>
    <br />
    <?php if(get_option('titles') == 'yes') { ?>
    <a href="<?php echo get_permalink($item->ID); ?>"> 
    <?php echo get_the_title($item->ID); ?> </a>
    <div>
      <?php
    $q = new WP_Query(array($item));
    if($q->have_posts()) : while($q->have_posts()) : $q->the_post();
        the_excerpt();
    endwhile;endif;
    ?>
    </div>

    <?php } ?>
    </li>
    <?php  }  ?>
    </ul>

It now shows the excerpt below the title.. But it only shows the excerpt of 1 post only.

1 Answer 1

0

Replace the code:

From:

<div>
  <?php
$q = new WP_Query(array($item));
if($q->have_posts()) : while($q->have_posts()) : $q->the_post();
    the_excerpt();
endwhile;endif;
?>
</div>

To:

<div><?php $post = get_post($item->ID); echo $post->post_excerpt; ?> </div>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.