david
david

Reputation: 375

how to add a static text on the blog list page of wordpress?

so, i created a child theme from oceanWP.

i decided to add in my functions.php.....


function echo_comment_id( $comment_id ) {
    if ( is_home() ){
        $content = 'hi there';
        echo $content;
    }
    return $content;
}
add_action( 'the_content', 'echo_comment_id', 10, 1 );

my 'hi there' prints out twice though...... cause of the echo. without the echo, nothing prints out.

im thinking it gets hidden or immediately goes away?

Upvotes: 0

Views: 1141

Answers (1)

Andy Tschiersch
Andy Tschiersch

Reputation: 3816

wpbf_main_content_open is not a native Wordpress hook, it seems to be a hook from the Page Builder Framework. Do you use the Page Builder Framework?

However, that what you want can be done with native functions.

Action Hook loop_start

// place this in your functions.php
add_action( 'loop_start', 'add_static_text_on_blog_list_page' );

function add_static_text_on_blog_list_page(  ) {

    // Check if this is the Blog-Post-Page and main query.
    if ( is_home() && is_main_query() ) {
        echo '<h1>Hey everyone!</h1><p>This is a quick intro.</p>';
    }

}

Another way is the Custom Blog Posts Index Page Template. Make a copy from the page.php (or home.php if exists in the Parent-Theme) and save it as home.php in your Child-Theme. Then you can add the static text to this template (before the lopp starts).

Upvotes: 1

Related Questions