[Support request] Show something after Post Title

Home Forums Support [Support request] Show something after Post Title

Home Forums Support Show something after Post Title

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #2250778
    René

    Hey,

    In the codes I saw that the function “the_title” takes parameter for before and after. Where can I enter it? In the dynamic text type field i only can edit the before, not the after.

    And can the parameters only be used for certain posts/categories?

    Code

    #2250913
    David
    Staff
    Customer Support

    Hi there,

    for the GP Dynamic Text type you would need to use the generate_dynamic_element_text filter.
    For example.

    Give the Headline block that you want to filter a CSS Class eg. dynamic-title

    Then you can use that in this PHP Snippet

    add_filter( 'generate_dynamic_element_text', function( $text, $block ) {
        if ( ! empty( $block['attrs']['className'] ) && 'dynamic-title' === $block['attrs']['className'] ) {
            $before = 'your before content';
            $after = 'your after content'
            $text = $before . $text . $after;
        }
    
        return $text;
    }, 10, 2 );
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.