• Resolved SocialBlogsite

    (@socialblogsite)


    So many things fail easily now in multisite wp that didn’t fail with a single blog…
    I’ll only mention one in this post: Posts are ALWAYS shown in full.

    I’ve tried setting $more =0 , 1, moved the variable up and down the code…
    I’ve tried setup_postdata($post) everywhere…
    I’ve tried installing the theme in another site…
    I’ve tried uninstalling plugins…

    The posts have no manual excerpt nor more tag… I just want the automatic excerpt to be generated automatically.

    Is there anything else I can try?

    Below is the code

    if (have_posts()): while (have_posts()) : the_post(); ?>
                  <article class="entry" id="post-<?php the_ID(); ?>">
                    <header class="postheader">
    
                      <h2><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h2><?php echo'<span class="postinfo postdate">'. get_post_snippet( 'CityName' ) . ', ';
    				the_date('', $span_w_city,'</span>'); ?>
                    </header>
                    <div class="post_content">
    
    		<?php global $more; $more = 0; the_content(__('(full article...)')); ?>
                      <?php the_tags(__('<div class="postfooter postinfo">Tags: '), ', ', ' — </div>'); ?>
                  	</div>
                    <!-- end Entry -->
                   </article>
    
    <?php endwhile; else: ?>
Viewing 15 replies - 1 through 15 (of 16 total)
  • Thread Starter SocialBlogsite

    (@socialblogsite)

    @esmi
    Thanks for the code. Sometimes a piece of code is faster than a thousand words!

    Unfortunatelly, as i said above, I already tried that. I’ve set that $more variable EVERYWHERE but it won’t work.

    Using the more tag works fine. A single page returns the whole content and an archive just the text until the more tag… but it’s the automatic excerpt (by word count) which won’t work.

    I ended up creating new template so I prevent worpdress deciding between full content or excerpt, but when I use the_excerpt() I can’t change the more link text.

    It always shows […] no link.

    the_excerpt doesn’t accept parameters, so my next mission would be to find a filter to get it. but I’d like to find WHY this is not working anyway.

    You can see my wp test bench at juiciolaboralpordespido.com.
    It uses the code you sent me (it’s a second loop, using the technique described in codex pages saving as temporary the original query and restoring it later, if that helps)

    The “reading” preferences are set to “show a summary” and just in case I switched it to full and back to summary to be double sure.

    If you see the article called “How to justify the quality of your link data” it’s NOT cut.
    The others use the more tag, that’s why they are shorter.

    Any idea?

    Add to functions.php:

    function my_continue_reading_link() {
    	return ' <a href="'. esc_url( get_permalink() ) . '">' . __( 'Continue reading <span class="meta-nav">→</span>', 'my' ) . '</a>';
    }
    function my_auto_excerpt_more( $more ) {
    	return ' …' . my_continue_reading_link();
    }
    add_filter( 'excerpt_more', 'my_auto_excerpt_more' );

    Then just use <?php the_excerpt();?> in your theme template file

    The posts have no manual excerpt nor more tag… I just want the automatic excerpt to be generated automatically.

    that is what the_excerpt() does – no setting of the $more in connection with the_content() will be able to do this if there is no ‘more-tag’ in the post (and even then it will just stop at the more-tag).

    but when I use the_excerpt() I can’t change the more link text.

    It always shows […] no link.

    you can’t have a individual ‘per-post’ link text, however, you can have a link with the_excerpt(), see:
    https://codex.www.ads-software.com/Function_Reference/the_excerpt#Make_the_.22read_more.22_link_to_the_post

    The others use the more tag, that’s why they are shorter.

    the only post with the ‘more-tag’ seems to be ‘Search Engine Usage in 2009 – Growth and Adoption’ – as mentioned before, you can have a link like that with the_excerpt() as well.

    Thread Starter SocialBlogsite

    (@socialblogsite)

    Oh my god.
    I’d NEVER imagined the_content() wouldn’t reduce the content automatically for archive pages!

    So there should something on the Reading Settings dashboard panel that clarifies it !

    e.g. “In order for summaries be displayed, you have to cut the text by hand with the more tag”.

    Offering the option like that makes us believe it’s possible out the box!

    Figure: The option says “summary” and there’s no “summary” field in the post editor.

    Thaks for the clarification.

    If you know of any filter that will enhance the_content tag with automatically generated excerpts, I’ll appreciate the tip.

    Offering the option like that makes us believe it’s possible out the box!

    Figure: The option says “summary” and there’s no “summary” field in the post editor.

    Look at that page again. Those settings refer to your RSS feed – not your site’s pages.

    Thread Starter SocialBlogsite

    (@socialblogsite)

    Stands to reason!

    I made it to work with a conditional is_single and using the_content() or the_excerpt() with wp’s recommended filter for the more link text.

    I feel like a hacker. I still can’t believe this is not in the normal behavior of the_content.

    Thanks a lot!

    Thread Starter SocialBlogsite

    (@socialblogsite)

    @alchymyth

    you can’t have a individual ‘per-post’ link text, however, you can have a link with the_excerpt(),

    What did you make you think I was trying to get a per-post link?

    What did you make you think I was trying to get a per-post link?

    my personal cautious interpretation of your words ‘but when I use the_excerpt() I can’t change the more link text.’ –
    and the fact that this would be possible using the ‘more-tag’ with the_content()

    this might be an oportunity to stop philosophizing about the codex and the wordpress functions, and to describe clearly what you would like to achieve.

    Thread Starter SocialBlogsite

    (@socialblogsite)

    It IS possible to include and choose the more link.
    What i wanted is to the_content() to trim the text for me, rather than me editing hundreds of posts of an existing blog. That way my layout will still be able to decide whether to show the whole text or just an excerpt, no conditionals, no extra template.

    Thanks for helping out as well as answering.

    What i wanted is to the_content() to trim the text for me, rather than me editing hundreds of posts of an existing blog.

    automatically trimming the text will also mean, that any formatting will be removed (as it would when using the_excerpt; while with the ‘more-tag’ and the_content, formatting will be conserved)

    this filter function https://pastebin.com/YYq6Na89 should turn the content of a post into an excerpt (basically with the same treatment as using ‘the_excerpt()’ would do) if there is no ‘more-tag’ in the post’s content;
    posts with the ‘more-tag’ will show the content up to the ‘more-tag’ with a ‘continue reading’ link;
    to show a link at the end of the ‘excerpted’ posts, you will need to follow this link.

    That way my layout will still be able to decide whether to show the whole text or just an excerpt, no conditionals, no extra template.

    how could a layout decide this?

    the decision is made by the template (and the suggested filter function) and the post author:
    ‘more-tag’ => content up to the ‘more-tag’ and formatted;
    no ‘more-tag’ => excerpt up to the limit set either by default (55 words) or by filter – unformatted;

    (a possible modification to the suggested filter code would allow to use the hand-written excerpt instead; this is not implemented in the code at this stage; further modifications would allow to restrict the filter to certain archives or so …)

    Thread Starter SocialBlogsite

    (@socialblogsite)

    how could a layout decide this?

    You know what I meant, but let me correct myself so others can follow:

    “That way the_content() tag can decide based in the queried posts (multiple or single) to use the excerpt or the full content” same way it does already, regardless of the template. It justs quits when there’s no more quicktag nor excerpt, as if in doing so it got into the_excerpt()’s way.

    I use to limit the ways my clients format their content in a similar way. “Use this for this, and that for that”, but when it could make it faster with a few lines of code, I go for it.

    but when it could make it faster with a few lines of code, I go for it.

    I would do the same. luckily, because wordpress is so flexible, this can literally be done with those few lines of code – if neccessary, make them very long lines …

    however, as not everybody has the same idea about the output in archives, therefore, in my personal opinion, this does not need to be included into the core functions of wordpress.

    (my part in this discussion ends here ??

    Thread Starter SocialBlogsite

    (@socialblogsite)

    @alchymyth

    You’re a genius!!

    Thanks for that function. It worked right out of the box.

    I promise I will study your function step by step as if I had to do it myself so I don’t lose the opportunity to learn all that you saved me from.

    You should put that in the more tag or excerpt documentation under “show the more link without a more tag”, or so.

    Thread Starter SocialBlogsite

    (@socialblogsite)

    …as not everybody has the same idea about the output in archives…

    You’re right. For that there could be an option, like the one for feeds, to show full text or teasers, in archive type pages.

    The idea here is to take advantage of simple designs using the same index.php for both multiple and single posts, leaving wp to decide when to use one or another.

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘setting more 1 or 0 won't trim the_content’ is closed to new replies.