Post teasers questions

Community Forums Forums Design Tips and Tricks Post teasers questions

This topic is: not resolved

This topic contains 4 replies, has 2 voices, and was last updated by  Elaine Griffin 1 year, 1 month ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #48636

    Elaine Griffin
    Participant
    Post count: 86

    Hello,
    I have a few questions about formatting post teasers.
    1. Is there a way to set the teaser to show the first 2 paragraphs?

    2. Is there a way to set the teaser to show the meta description?

    3. Is there a way to keep it from stripping the formatting?

    I don’t really have a link to a site, because I’m working on multiple sites who’s owners are wondering about these things.

    Thanks for any help – it’s always appreciated!
    Elaine

    #48649

    braddalton
    Participant
    Post count: 9212

    1. You would need a custom loop with variables to display the first 2 paragraphs. Or you could use the Genesis > Content Archives > Content Limit

    2. You can use the native Excerpts function included in all edit post screens. You can add the meta description manually as an excerpt.

    If adding the excerpt manually, you may use (some) HTML formatting and the tags will not be stripped


    Specializing In StudioPress Child Theme Customization.
    500+ StudioPress Tutorials

    #48665

    Elaine Griffin
    Participant
    Post count: 86

    Thank you for this!
    Numbers 2 and 3 I get, but could you go into a little more detail about 1? I am only very slowly understanding any PHP.
    Thank you so much!

    #48673

    braddalton
    Participant
    Post count: 9212

    You would need something like this

    Or you could use the Genesis > Content Archives > Content Limit but it cannot be set to the first 2 paragraphs, only a character limit.

    I have written some code which uses the amount of paragraphs in a custom function but would need to modify it to work the way you want it to.

    Here’s an example where you can take the variables and use them to modify the post excerpts to display 2 paragraphs.

    Would require a fair amount of modification and testing.

    https://gist.github.com/5150240


    Specializing In StudioPress Child Theme Customization.
    500+ StudioPress Tutorials

    #48703

    Elaine Griffin
    Participant
    Post count: 86

    Okay, I did see those examples in my search.
    This is what I was thinking:
    <?php
    //* Do NOT include the opening php tag

    //* Modify the length of post excerpts
    add_filter( ‘excerpt_length’, ‘custom_excerpt_length’ );
    function custom_excerpt_length( $length ) {
    return 50; // pull first 50 words
    }

    What I was confused about was whether or not I could write:
    retrun 2; // pull first 2 paragraphs

    Thank you so much!

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.