• Okay this must be a really noob question…

    Say the relevant filter in the php is defined like:

    $content        = sprintf('<%1$s class="entry-title %2$s">%3$s</%1$s>',
                    apply_filters( 'tc_content_title_tag' , 'h1' ),
                    apply_filters( 'tc_content_title_icon', 'format-icon' ),
                    get_the_title( $page_for_post_id )
               );
    $content        = apply_filters( 'tc_page_for_post_header_content', $content );

    So I’m trying to use the filter ‘tc_page_for_post_header_content’ to add itemprop="itemReviewed" inside the <h1> tag.

    So this is what I tried in my child theme’s functions.php:

    add filter( 'tc_page_for_post_header_content' , 'add_structured_title');
    function add_structured_title() {
        if (is_singular('post') ) {
            return sprintf('<%1$s itemprop="itemReviewed" class="entry-title %2$s">%3$s</%1$s>',
                    apply_filters( 'tc_content_title_tag' , 'h1' ),
                    apply_filters( 'tc_content_title_icon', 'format-icon' ),
                    get_the_title( $page_for_post_id )
               );
        }
        else {
            return sprintf('<%1$s class="entry-title %2$s">%3$s</%1$s>',
                    apply_filters( 'tc_content_title_tag' , 'h1' ),
                    apply_filters( 'tc_content_title_icon', 'format-icon' ),
                    get_the_title( $page_for_post_id )
               );
        }
    }

    As you can imagine that failed terribly.

    I think I probably have to add $page_for_post_id as an argument in the function? Also, how do I deal with the filter calling other filters that is outside my child theme’s functions.php?

    Thanks for your help! ??

  • The topic ‘How to use filters that contain other filters?’ is closed to new replies.