External page to output post snippets with excerpt

Support Forums for LiveMesh Themes & Plugins Forums Invent Theme Support External page to output post snippets with excerpt

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #26378
    Palmtreepalmtree
    Participant

    Hello Code Master,

    I am trying to create an external custom page within the theme to output post snippets. So far I have sorted out output category name, number of post, permalink and title etc but I am having difficulty to output image and excerpt which I want the same or at least similar way to the invent default output method. For the excerpt, I don’t want to use <?php the_excerpt(); ?> because the number of output characters don’t match with the theme default excerpt and also it doesn’t output “…” at the end. I’ve tried something like <? echo mo_truncate_string(get_the_excerpt(), $excerpt_count); ?> but didn’t work. It would be so great if you could give me advise.

    Thank you very much.
    Palmtree

    #26385
    VeenaVeena
    Moderator

    This should work –

    
    echo mo_truncate_string(get_the_excerpt(), $excerpt_count);
    

    Are you trying to create a custom post type?

    Can you try this –

    
    echo wp_trim_words( get_the_excerpt(), 20);
    

    https://codex.wordpress.org/Function_Reference/wp_trim_words

    #26391
    Palmtreepalmtree
    Participant

    Thank you phoenix for your reply.
    The first one worked but only printed first one word and followed by “…”.
    So I have modified it to something like <?php echo mo_truncate_string(get_the_excerpt(), 200) . '..'; ?> And it seems like working now… But I don’t get how this 200 really mean. Because by changing this value to 400 doesn’t make output text volume doubled. Also I had to put two dots (one less) '..' to output three dots.

    Could I also ask about thumnail image?
    <?php if ( has_post_thumbnail() ) { the_post_thumbnail(); } ?> This one works but is that the same method as invent theme default snippet image output?

    I want the output method to be consistent to the default one..

    Any of your advise is appreciated:D!

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘Invent Theme Support’ is closed to new topics and replies.