Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #382778

    Not too long ago I wanted to know how to cut off excerpts (on a blog page by using the blog posts element of the builder) at the read more tag, instead of using a certain amount of characters/words for cutting them off:
    https://kriesi.at/support/topic/cut-excerpt-off-at-more-tag-instead-of-using-wordcharacter-count/

    The solution worked great. I added this code to my childs function.php file:

    add_filter( 'post-format-standard', 'avia_category_content_filter', 15, 1);
    function avia_category_content_filter($current_post)
    {
    if(!is_single())
    {
    	global $more;
    	$more = 0;
    	$current_post['content'] =  get_the_content(__('Read more','avia_framework').'<span class="more-link-arrow">  &rarr;</span>');
    }
    return $current_post;
    }

    Just wanted to let you guys know this does only work for standard post types; for example, it doesn’t work for image post types. So I had to change the code a bit, and by trial and error I found out it should be someting like this (note the second line):

    add_filter( 'post-format-standard', 'avia_category_content_filter', 15, 1);
    add_filter( 'post-format-image', 'avia_category_content_filter', 15, 1);
    function avia_category_content_filter($current_post)
    {
    if(!is_single())
    {
    	global $more;
    	$more = 0;
    	$current_post['content'] =  get_the_content(__('Read more','avia_framework').'<span class="more-link-arrow">  &rarr;</span>');
    }
    return $current_post;
    }

    Just wanted to let you know, as well wondering if there’s a general/better code to assign the filter to all post types…

    #383087

    Hey Marc!

    Thanky you for using our theme and your feedback.

    No, there is no better way, as this filter is always called in comjunction with the post type. WP does not support to add filters with wild cards.

    Cheers!
    Günter

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.