WordPress.org

Ready to get started?Download WordPress

Forums

Quark
[resolved] Using custom field to overwrite default H1 (4 posts)

  1. CaptRobovski
    Member
    Posted 11 months ago #

    Hi Ahortin,

    Firstly, just want to say how great your theme is. I'm familiar with WordPress but new to actually building a site with it, so it's been really handy having a lightweight yet powerful theme to work with.

    I've got a couple of questions I'm having trouble with but I'll spread them into separate posts as they might help others in future.

    I'd like to change the default H1 heading that appears on a page (i.e. the page title) by using a custom field. By default WordPress puts whatever I put as the Page Title as an H1 Heading. I'd like to swap this out for a keyword optimised heading instead. I know I could add the desired content as a page title, manually amend the slug and create a custom menu, but that's messy for the page admin.

    I've read that you can use a custom field and amend the Pages.php file to display the custom field in place of the H1 heading. However, I can't work out how to do this with the Quark theme. I've read elsewhere that I'd need to edit Functions.php, but I can't fathom that either!

    Here's the links I've been trying to work from. Any ideas?

    Using pages.php: http://www.getwpress.com/seo/h1-hack-for-wordpress-pages/

    Using functions.php: http://halgatewood.com/wordpress-function-check-for-h1-custom-field/
    Many thanks,

    Rob

  2. ahortin
    Member
    Theme Author

    Posted 11 months ago #

    I'd suggest you use Advanced Custom Fields (ACF) to add a new custom meta box to the page templates.

    You'll then need to change each page template content.php, content-page.php etc.. to use this new custom field.

    The ACF website has some great documentation and examples on how you use the fields you create.

  3. CaptRobovski
    Member
    Posted 11 months ago #

    Hi Ahortin,

    Thanks for your reply - I'll take a look at ACF and hopefully that will do the trick. When I had a go at adding custom fields (the standard WordPress option) last night it wasn't letting me add any.

    Ah I see! Presumably that allows for a greater level of control per page, which makes sense.

    I'll have a go and will post back to let you know if this thread is resolved :)

  4. CaptRobovski
    Member
    Posted 11 months ago #

    Just been able to take a look at Advanced Custom Fields and was able to get this to work. As I only wanted to change the H1 on standard pages I only needed to change the content-pages.php file and not any of the blog specific ones.

    Thanks again for your help.

    Rob

Reply

You must log in to post.

About this Theme

About this Topic