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 11 months, 3 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: 9415

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

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


    Specializing In StudioPress Child Theme Customization.
    500+ StudioPress Tutorials

    #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: 9415

    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/


    Specializing In StudioPress Child Theme Customization.
    500+ StudioPress Tutorials

    #61859

    francky
    Participant
    Post count: 41

    @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: 9415

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


    Specializing In StudioPress Child Theme Customization.
    500+ StudioPress Tutorials

    #61892

    braddalton
    Participant
    Post count: 9415

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


    Specializing In StudioPress Child Theme Customization.
    500+ StudioPress Tutorials

    #61918

    francky
    Participant
    Post count: 41

    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: 9415

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

    You would need to add it to a custom function.


    Specializing In StudioPress Child Theme Customization.
    500+ StudioPress Tutorials

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

You must be logged in to reply to this topic.