Site logo

Archived topic

Centering Headings

11 replies · Started by Stuart on July 1, 2019

Viewing posts 1–12 of 12

Is there not a way to center headings in pages and posts? I haven't seen an option for that and all the text automatically goes leftward.

Hi there,

we are looking at possibly adding them as Customizer options, if there is enough interest. But it takes 3 lines of CSS to currently do it:

h1.entry-title {
    text-align: center;
}

Thank you. How and where would I enter this code? And can it be used to center headings in some pages but not others?

So you can add it to the Customizer > Additional CSS - and it will apply to all pages and posts.
To set it to specific pages / posts you would need to specify the unique page-id / post-id for each one in the CSS. So simpler way is to:

1. Create a new Hook Element:
https://docs.generatepress.com/article/hooks-element-overview/

2. Add this as your content:

<style>
h1.entry-title {
    text-align: center;
}
</style>

3. Select the WP_head Hook from the Hook list

4. On Display Rules set the posts / pages you wish it to work on. You can use taxonomies ( categories and tags ) if you like. Or set it to the Entire Site and then exclude the ones you don't want it on.

What is the definition of a "hook"?

Simple put it is a 'placeholder' left in the templates code - which allows a user to 'hook' in their own content.

The WP_Head hook places the content / code inside the <head></head> of your website.

I see. Thank you.

Hello GP Team, has centering headings been added to the new typography module, or does it still require custom CSS? I looked but didn't see it.
Harry

Hi Harry,

text-align is not included in the typography settings.

So CSS is still required.

OK, thanks. Easy to do.
Harry

No problem :)

This archived topic is closed to new replies.