• We are using the Hemingway theme and would like to add some static text to the top of the blog (posts) page, (which is not our home page).

    How can this be done? When trying to edit the Blog page it does not display a text entry area (as other pages do when editing).

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter sailpilot

    (@sailpilot)

    I just found this thread about the same topic but a different theme at https://wordpress.org/support/topic/add-a-static-paragraph-to-post-page/

    How can this be done for the Hemingway theme using the child theme we have?

    function neve_child_add_blog_description() {
    	echo 'The text that you need';
    }
    add_action( 'neve_before_posts_loop', 'neve_child_add_blog_description' );
    • This reply was modified 2 years, 1 month ago by sailpilot.
    Theme Author Anders Norén

    (@anlino)

    Hi @sailpilot,

    Hemingway doesn’t trigger an action before the posts loop, so there’s not an equivalent solution to the one you posted. What you can do is to add a function hooked to the get_the_archive_title filter, and add a conditional checking for the blog archive page. Like so:

    function xxx_filter_archive_title( $title ) {
    
    	if ( is_home() ) {
    		$title = 'This is the home title';
    	}
    
    	return $title;
    
    }
    add_filter( 'get_the_archive_title', 'xxx_filter_archive_title' );

    You can also hook it to the get_the_archive_description filter, if you prefer the way that looks.

    — Anders

    Thread Starter sailpilot

    (@sailpilot)

    Sorry I had to work on some other things and didn’t get to this until now.

    I inserted the above function in our function.php file in the Hemingway child theme but it doesn’t seem to do anything.

    Am I missing something? or does that function need some modification?

    Thanks

    Theme Author Anders Norén

    (@anlino)

    @sailpilot Try changing the last line to this:

    add_filter( 'get_the_archive_title', 'xxx_filter_archive_title', 20 );

    Thread Starter sailpilot

    (@sailpilot)

    Thanks but it still doesn’t seem to work.

    Just to summarize:

    Our home page is a static About page, it is not the Blog (posts) page.

    We have a Hemingway child theme that has a funtions.php file where I inserted your suggested function.

    Is there something that I need to change on your function for our implementation or is it supposed to work as is for anyone using the Hemingway theme?

    Theme Author Anders Norén

    (@anlino)

    Hi @sailpilot,

    I’ve verified this as working on my local installation, with a Hemingway child theme with the front page set to a static page and a separate page set as the page for posts. You call it a funtions.php file in your post – is it spelled correctly in the child theme folder? Are other functions in the file working properly?

    — Anders

    Thread Starter sailpilot

    (@sailpilot)

    Hi @anlino,

    Sorry that was a typo in my last message. It is functions.php in the child theme. And there are several other functions in that file that all work.

    Just to be clear I just took your function (below) and just pasted it into the child functions.php file without any changes and I can’t get it to work. I guess there must be some conflict with something?

    function xxx_filter_archive_title( $title ) {
    
    	if ( is_home() ) {
    		$title = 'This is the home title';
    	}
    
    	return $title;
    
    }
    add_filter( 'get_the_archive_title', 'xxx_filter_archive_title', 20 );
Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘static text on blog page’ is closed to new replies.