• Resolved Sibylle

    (@sibweber)


    I’m new to block themes and FSE, and while I have followed Carolina Nymark’s tutorial, I am still confused about a couple of things. Here is one of them:

    The default block <!– wp:site-title /–> outputs the site title as an h1 element. I would like to change this, as I need the h1 for the titles of each post or page.

    How do I edit the code that is generated by these blocks? Or is there another way to output only the site-title itself?

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • If you’re just building your own site, you probably want to change the heading level from the editor since you’re probably going to use this block only once.

    If you’re building a theme for distribution (or you simply prefer to work from code), the following will set an instance of the Site Title’s default heading level to h2 (this can still be changed from the editor):

    <!-- wp:site-title {"level":2} /-->

    Please see: https://developer.www.ads-software.com/block-editor/reference-guides/block-api/block-attributes/

    (I don’t know if it’s possible to output just the Site Title without any markup.)

    Good luck!

    Thread Starter Sibylle

    (@sibweber)

    Thanks George, is there a way to make it a different element? Like a div?

    Thread Starter Sibylle

    (@sibweber)

    I just found an answer to this by checking out the twentytwentythree theme: “level”: 0 will wrap the site-title in a <p>-Element instead of a heading.

    <!-- wp:site-title {"level":0} /-->
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to edit default code of wp:site-title block’ is closed to new replies.