Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #1495858

    Hi,
    How can I style the excerpt belonging to a post? I would like to use focuscolors on certain words and spread it over multiple lines. Is there a possibility for? Can I use inline html or something like that?

    Regards Erwin

    #1495873

    Hey Erwin,

    Thank you for the inquiry.

    Yes, it is possible to add inline html to the post excerpt. You can go to Posts > All Posts, edit the post you want to modify, and add your custom html directly in the excerpt field. For example, you can wrap certain words in a span tag with a custom class, like this:

    
    This is the <span class="av-highlight">highlighted word</span> in the excerpt.
    

    Then you can style that class using custom css in Enfold > General Styling > Quick CSS or via Appearance > Customize > Additional CSS:

    
    .av-highlight {
        color: orange;
    }
    

    Just keep in mind that the excerpt field in WordPress does not show a visual editor by default, so you would need to type the html directly in the plain text field. Also, some themes or plugins may strip html tags from the excerpt, but Enfold generally allows basic inline html tags like span to pass through.

    Let us know if you have more questions.

    Best regards,
    Ismael

    #1495883

    Hi Ismael,

    On my site I’m using a post grid and a masonry gallery, both should show title and excerpt. Within the post grid it shows the inline html as you suggested, in the masonry gallery it doesn’t. Any idea how to solve this?

    Best regards,

    Erwin

    #1495884

    try in your child-theme functions.php:

    function my_avf_masonry_loop_entry_content($loop_excerpt, $entry) {
      $loop_excerpt = $entry->post_excerpt;
      return $loop_excerpt;
    }
    add_filter('avf_masonry_loop_entry_content', 'my_avf_masonry_loop_entry_content', 10, 2);

    or maybe better only allow some tags that are not stripped:

    function my_avf_masonry_loop_entry_content($loop_excerpt, $entry) {
      $loop_excerpt = strip_tags( ($entry->post_excerpt) , '<br><p><span>'  );
      return $loop_excerpt;
    }
    add_filter('avf_masonry_loop_entry_content', 'my_avf_masonry_loop_entry_content', 10, 2);
    #1495885

    Thank you, I’ve used the second one and it works great!

    Regards,
    Erwin

    #1495888

    ok – the only difference is that you only allow in this case : br-tags; p-tags and span-tags

    #1495889

    Yes, I understand, but that will be enough. I will only be using the br and span-tags.

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