0

I'm having a hard time figuring out how to set either the excerpt or the full content on my posts. I'm using post format, so far everything works, but when I click on a specific post, only the excerpt is displayed in the full post (because only the excerpt is set on format-video, for ex.).

I would like my post formats to display the excerpt when it's on loop.php (home page), and the full content when it's on single.php I am bad at php, but here is my code (which is obviously not working for a reason)

<?php if ( is_loop() ) { ?>
        <?php custom_excerpt('custom_index'); ?>    
    <?php } elseif ( is_single() ) : { ?>   
        <?php the_content(); ?>
    <?php } ?>
    <?php endif; ?>

Could anyone tell me where is the mistake in my code ? Or is there a better solution to perform what I'm trying to do ?

1
  • 1
    is_loop() should be is_home(). Also, you are mixing syntax here, only use curlies to enclose your statements Nov 7, 2015 at 9:04

1 Answer 1

1

You can try this.

<?php 
      if ( is_single() )
              the_content();
      else
              custom_excerpt('custom_index'); 
    ?>

in your post loop.It prints content if the post is single.php page otherwise custom_excerpt() data.

1
  • That's indeed the easiest way, I complicated my code too much for nothing. Thank you
    – dbsso
    Nov 7, 2015 at 10:18

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.