Community Forums › Forums › Archived Forums › General Discussion › Customize Content Archive Content Limit in Archive Template?
Tagged: content archive limit, Custom Post Type
- This topic has 8 replies, 3 voices, and was last updated 12 years, 7 months ago by
Brad Dalton.
-
AuthorPosts
-
September 3, 2013 at 7:18 pm #60544
scott9s
MemberDoes 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/September 3, 2013 at 8:23 pm #60550Brad Dalton
ParticipantWhat you can do is is conditionally control the limit in the excerpts.
Please let me know if you need help customizing this code.
September 3, 2013 at 8:48 pm #60554scott9s
MemberI 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.
September 3, 2013 at 9:43 pm #60564Brad Dalton
ParticipantThat'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/
September 11, 2013 at 3:48 am #61859francky
Member@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!
September 11, 2013 at 6:09 am #61889Brad Dalton
ParticipantSeptember 11, 2013 at 6:23 am #61892Brad Dalton
ParticipantActually, it can be done as i just saw some code for it here http://wordpress.stackexchange.com/questions/69436/excerpt-in-characters
September 11, 2013 at 8:31 am #61918francky
MemberThank 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; }September 11, 2013 at 10:53 am #61963Brad Dalton
ParticipantIts not my code and comes from the WordPress.org Codex.
You would need to add it to a custom function.
-
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.