Forums

more shortcode as excerpt for Twentyten instead of fixed length (16 posts)

  1. adastra
    Member
    Posted 1 year ago #

    The title says it all - I want the excerpt of my post to be displayed on the front page to be the one in front of the <!--more--> tag instead of a fixed amount of characters. I've tried Google, Forum searches, etc. but I couldn't find anything to help me.

    Thanks in advance!

  2. adastra
    Member
    Posted 1 year ago #

    Can anyone help with this? I'm sure it's easy, I just don't get how I can activate it in the twentyten theme!

  3. alchymyth
    The Sweeper
    Posted 1 year ago #

    what you are asking for is the default behaviour of twenty ten.

    what exact theme are you using?
    have you made any modification to it?

    link to your site?

  4. adastra
    Member
    Posted 1 year ago #

    It's working on category pages, but not on the index page. This is the code where the code for the index page comes from:

    <?php if ( is_front_page() || is_archive() || is_search() ) : // Only display excerpts for archives and search. ?>
    			<div class="entry-summary">
    				<?php if ( has_post_thumbnail() ) { ?>
              <div class="post-image"><?php the_post_thumbnail( 'full' ); ?></div>
            <?php } ?>
    				<?php the_excerpt(); ?>
            <div class="clear"></div>
    			</div><!-- .entry-summary -->
    	<?php else : ?>
    			<div class="entry-content">
    				<?php the_content( __( '<span class="meta-nav">Continue reading</span>', 'twentyten' ) ); ?>
    				<?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'twentyten' ), 'after' => '</div>' ) ); ?>
    			</div><!-- .entry-content -->
    	<?php endif; ?>

    When I change the_excerpt() to the_content(), or when I remove is_front_page(), I ALWAYS get the entire entry on the front page and not my custom excerpt.

  5. alchymyth
    The Sweeper
    Posted 1 year ago #

    When I change the_excerpt() to the_content(), or when I remove is_front_page(), I ALWAYS get the entire entry on the front page and not my custom excerpt.

    do you want to use the 'more tag' and have that control the length of your post on the front page, or do you want to show the handwritten custom excerpt?

    you could try and replace is_front_page() with is_home(), or add || is_home() to the conditional statement;

    http://codex.wordpress.org/Conditional_Tags

  6. adastra
    Member
    Posted 1 year ago #

    Thanks!

    Unfortunately is_home() doesn't do any difference to my template. If I add it or replace is_front_page() with it I'm still not seeing my custom excerpt (the content before the <!--more--> tag in my post), neither when I use the_excerpt() nor when I use the_content()...

  7. alchymyth
    The Sweeper
    Posted 1 year ago #

    sometimes, plugins interfere with the normal working;
    try to deactivate all plugins; if this solves the problem, re-activate one plugin at a time, to see which is causing the trouble.

  8. adastra
    Member
    Posted 1 year ago #

    I think I just figured out that the problem is somewhere in my modified index.php, because when I replace the modified index with the default twentyten one, it works fine. However, I can't find what's wrong with it..?!

    [code moderated according to Forum Rules - please use the pastebin]

  9. alchymyth
    The Sweeper
    Posted 1 year ago #

    possibly, because you have queried a 'cat' parameter;

    try to replace this query
    query_posts('cat=-5');
    with:
    (example)
    global $query_string; query_posts($query_string . '&cat=-5');

    (i can't remember the cat id you were excluding)

  10. adastra
    Member
    Posted 1 year ago #

    Still no luck :(

    When I remove the query_posts completely, I get the same page as the one I'm querying for my "intro div". I assume it's something to do with that, because when I remove all the code in the intro div, it works fine.

    Do I have to tell query posts something more specific that it should query posts for the index?!

    The code is here: http://pastebin.com/npPCZ60Z

  11. alchymyth
    The Sweeper
    Posted 1 year ago #

    I get the same page as the one I'm querying for my "intro div"

    thanks for the hint - i missed that bit -
    try to reset the data after the first loop, after line 32:

    <?php endwhile; // end of the loop.
    wp_reset_query(); ?>
  12. adastra
    Member
    Posted 1 year ago #

    Hmmpf, still not working :(
    I'm very clueless...

  13. adastra
    Member
    Posted 1 year ago #

    It also doesn't work when I replace get_template_part('loop', 'index'); with it's equivalent from the loop.php. I'm out of ideas. Is there anything else I can try?

  14. adastra
    Member
    Posted 1 year ago #

    I've also tried completely replacing the part of the code which loads my page excerpt before the posts loop with a "manual" SQL query. The <!--more--> then works, but it doesn't display the "read more" links - neither with the_excerpt() nor withthe_content()

    *headdesk*

  15. esmi
    Theme Diva & Forum Moderator
    Posted 1 year ago #

    You need to use the Loop and the_content() if you also want to use the more tag.

  16. adastra
    Member
    Posted 12 months ago #

    I'm still having the same problem. I've tried wp_reset_query();, rewind_posts(); and wp_reset_postdata();, but nothing helps. Still the same weird phenomenon.

Topic Closed

This topic has been closed to new replies.

About this Topic