Archived topic
Adding code to Blog page
13 replies · Started by Michael on February 9, 2020
Hi all,
I have set up my Blog page to display the posts on my site. However in so doing it removed the HTML code I had set up on the page to display the page title as per the other pages. I cannot see any way to add the HTML code back in - please could you tell me how I go about doing this?
Hi there,
I'm not sure if I understand.
What code are you trying to add to the blog page?
The link above shows "default backend - 404" to me.
Hi Leo,
Sorry, the page is now:
https://reclaimdesign.org/blog.html/
I'd like to add this at the top of the page as per the other pages:
<table class="header">
<tbody>
<tr>
<td class="center">
<header>
<h1>Blog</h1>
</header>
</td>
</tr>
</tbody>
</table>
How are you adding it on other pages? Just inside the content?
The posts page cannot be edited like a normal static page so you'd need to use a hook with hook elements:
https://docs.generatepress.com/article/hooks-element-overview/
https://docs.generatepress.com/article/hooks-visual-guide/
Hi Leo, I just added html on other pages via the page edit area in the WP dashboard. I just need to add the title to the blog page as it's the only one missing. Can I do that with a hook?
Yup either hook element or header element should both work:
https://docs.generatepress.com/article/hooks-element-overview/
https://docs.generatepress.com/article/header-element-overview/
Hi Leo, um, please can I get some help with how to code that just for the blog page? My brain is flat-lining ;)
Try creating a header element, add that as the page hero content:
https://docs.generatepress.com/article/how-to-create-a-page-hero/#step-1-add-the-content
Under the display rules, select Blog as Location.
Hi Leo,
For some reason I don't see the menu option mentiond:
To create a new Header Element, go to Appearance > Elements and click “Add New”. From the Element dropdown list, choose “Header”.
Is there a plugin I need or something like that? I had to turn off a bunch of plugins whilst troubleshooting site stuff. I left the GP one one though
Sorry Leo, I have found it. It works but I was hoping to place the header underneath the social media icons as per my other pages eg:
Hi there,
you can use a Hook Element instead of the Header Element - the before_main_content hook should put it in the right place.
If that is the same hook you have for your social icons then increase the Priority value of this new hook to move it below.
Hi David, you're a legend Sir. That works too. Thank you very much - you are saving what little hair I have left ;)
You're welcome