[Resolved] Put a character before and/or after the title

Home Forums Support [Resolved] Put a character before and/or after the title

Home Forums Support Put a character before and/or after the title

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #2380022
    Ediciones Desnivel SL

    I have had no problem in other templates inserting a “-” or a “.” at the beginning or end of post titles.
    In Generatepress I can’t understand how to make this modification. I have looked at the code, the functions…
    I have tried using generate_get_the_title_parameters, but it only works for Archive (still changing “if ( ! is_singular()…” for “if ( is_singular()…”).

    I know generate_after_entry_title, but it’s not what I’m looking for, because it puts the character below, not at the end of the title.
    Thanks for you the help.

    #2380226
    David
    Staff
    Customer Support

    Hi there,

    you can do something like this:

    
    add_filter( 'generate_get_the_title_parameters', 'filter_custom_post_title' );
    function filter_custom_post_title( $params ) {
    
        if ( is_single() ){
            $prefix = 'My prefix ';
            $suffix = ' My suffix';
        } 
    	
        if ( $prefix || $suffix ) {
            $params = array(
                'before' => sprintf(
                    '<h1 class="entry-title"%1$s>%2$s ',
                    'microdata' === generate_get_schema_type() ? ' itemprop="headline"' : '',
                    $prefix
                ),
                'after' => sprintf(
                    '%1$s</h1>',
                    $suffix
                ),
            );
        }
        return $params;
    }
    #2380735
    Ediciones Desnivel SL

    Thank you very much! 🙌

    #2380924
    David
    Staff
    Customer Support

    You’re welcome

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