[Resolved] Text before photo in blog post

Home Forums Support [Resolved] Text before photo in blog post

Home Forums Support Text before photo in blog post

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #2312069
    Tomasz

    How can I add text before a photo to a new post?
    Currently I have Block: H1, Meta, Main Picture.
    When creating an entry, I want to add text before the image – this will be an introduction to the article and it must not be repeated with the text in the entry.

    1234-webp
    Schowek01

    #2312389
    David
    Staff
    Customer Support

    Hi there,

    You’re using a Block Element to display your Title and Post Meta – Correct ?

    You can edit that and insert a GB Headline Block and use its Dynamic data options to display Post Meta and use a custom field.

    You just then need to add that custom field to your posts to store your paragraph

    #2312824
    Tomasz

    Yes, I use the block element as a header for entries and as posts in the category archive.

    This solution that you gave me came up with earlier, but it has one drawback for me. It works in the entry, but in the category archive, the character limit does not work, e.g. 15 words to fit in two lines. Like on photos. And I would not like to set the word limit in this heading in the entry to 15 words only as much as I need but then the archive does not work.

    [url=https://ibb.co/LxVrV7D][img]https://i.ibb.co/McFfF0y/Schowek01.jpg[/img][/url]
    [url=https://ibb.co/tD6nyk1][img]https://i.ibb.co/TtGJzpN/Schowek011.jpg[/img][/url]

    #2312837
    Tomasz

    Looks like I handled it. I added this PHP code:

    add_filter( 'get_the_excerpt', function( $excerpt, $post ) {
        if ( has_excerpt( $post ) ) {
            $excerpt_length = apply_filters( 'excerpt_length', 15 );
            $excerpt_more   = apply_filters( 'excerpt_more', ' ' . '[…]' );
            $excerpt        = wp_trim_words( $excerpt, $excerpt_length, $excerpt_more );
        }
        return $excerpt;
    }, 10, 2 );

    Could it possibly be done better somehow?

    #2313244
    David
    Staff
    Customer Support

    Ah – ok if you’re using the Manual Excerpt then that code you have is required.

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