Customize Content Archive Content Limit in Archive Template?

Community Forums Forums General Discussion Customize Content Archive Content Limit in Archive Template?

This topic is: not resolved

This topic contains 8 replies, has 3 voices, and was last updated by  braddalton 7 months, 2 weeks ago.

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #60544

    scott9s
    Participant
    Post count: 4

    Does anyone know how to customize the content archive content limit different for each archive post type?

    For example, when I am on the “posts”, I want the content archive limit to be 500 characters. However, when I am on the archive for the custom post type of “photos”, I want the content archive limit to be 0 characters.

    In genesis theme settings, its an all or nothing. I don’t see a way to customize it by post type.

    https://www.screenflex.com/photos/
    #60550

    braddalton
    Participant
    Post count: 7473

    What you can do is is conditionally control the limit in the excerpts.

    Please let me know if you need help customizing this code.


    WordPress Developer & Consultant
    Brad Dalton400+ StudioPress Tutorials & 1200+ Code snippets

    #60554

    scott9s
    Participant
    Post count: 4

    I tried the excerpt length, and that doesn’t work when you are using the content archive length in the genesis settings.

    Thanks for the suggestion.

    #60564

    braddalton
    Participant
    Post count: 7473

    That’s right. The Content Archives control the content length when using the content limit.

    Try using the excerpt rather than content limit in the Genesis Settings.

    I tested this and it works perfectly with the code above.

    I did write a full post about this recently that may help. http://wpsites.net/web-design/set-post-content-limits-for-home-blog-archive-pages/


    WordPress Developer & Consultant
    Brad Dalton400+ StudioPress Tutorials & 1200+ Code snippets

    #61859

    francky
    Participant
    Post count: 39

    @braddalton
    I just checked the code, but how can I change the content limit to specify the number of letters and not words?
    I mean limiting to letters and not words;
    CHANGING: This is an example text and if you want … [read more]
    TO: This is an example text and if you wa … [read more]

    I shall appreciate your help Sir!

    #61889

    braddalton
    Participant
    Post count: 7473

    Can’t be done as far as i know. It uses the words not characters.


    WordPress Developer & Consultant
    Brad Dalton400+ StudioPress Tutorials & 1200+ Code snippets

    #61892

    braddalton
    Participant
    Post count: 7473

    Actually, it can be done as i just saw some code for it here http://wordpress.stackexchange.com/questions/69436/excerpt-in-characters


    WordPress Developer & Consultant
    Brad Dalton400+ StudioPress Tutorials & 1200+ Code snippets

    #61918

    francky
    Participant
    Post count: 39

    Thank you @braddalton

    I tried the code below but it doesn’t work. Sorry I’m not good a coding…

    function get_the_popular_excerpt(){
    $excerpt = get_the_content();
    $excerpt = preg_replace(" (\[.*?\])",'',$excerpt);
    $excerpt = strip_shortcodes($excerpt);
    $excerpt = strip_tags($excerpt);
    $excerpt = substr($excerpt, 0, 400);
    $excerpt = substr($excerpt, 0, strripos($excerpt, " "));
    $excerpt = trim(preg_replace( '/\s+/', ' ', $excerpt));
    $excerpt = $excerpt.'... <a href="'.$permalink.'">more</a>';
    return $excerpt;
    }
    #61963

    braddalton
    Participant
    Post count: 7473

    Its not my code and comes from the WordPress.org Codex.

    You would need to add it to a custom function.


    WordPress Developer & Consultant
    Brad Dalton400+ StudioPress Tutorials & 1200+ Code snippets

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

You must be logged in to reply to this topic.