0

What I'm trying to achieve is quite simple (in my mind).

On the homepage, my blog presents the list of latest posts and I'm ok with it. I just want to add an introduction (three lines of text) before this list of posts.

For some time, I've achieved this by having a fake post with altered publication time (in order to stay first) but now that I'm implementing a newsletter with the latest posts, it starts interfering.

Some ideas on how to fix this? I've already set up a child theme, maybe this come in handy ?

1 Answer 1

0

Two methods:

Edit the template file:

Find the template file that renders your posts (most likely index.php) and find the place where the post loop starts.

Something like:

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>

Any content added before this code will be shown before your blog posts.

Insert via hook:

add_action( 'loop_start', 'wpse107113_loop_start' );
function wpse107113_loop_start( $query ){
    if( $query->is_main_query() ){
        echo "<p>Hello World!</p>";
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.