[Resolved] Editing meta title and meta description in each page

Home Forums Support [Resolved] Editing meta title and meta description in each page

Home Forums Support Editing meta title and meta description in each page

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1284658
    Ricardo

    Hi,

    I’m sorry if this out of your scope but could you give me some orientation on how to edit meta title and meta description (or how to edit <head>) on each page and post, without installing heavy plugins like yoast SEO?

    Thanks in advance,
    Ricardo

    #1285049
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    You would need to add custom fields to your posts/pages. A plugin like ACF might help with that.

    Then you can do this:

    add_action( 'wp_head', function() {
        if ( is_singular() ) {
            $meta_title = get_post_meta( get_the_ID(), 'your_meta_title_custom_field', true );
            $meta_desc = get_post_meta( get_the_ID(), 'your_meta_description_custom_field', true );
    
            if ( $meta_title ) {
                printf( '<meta name="title" content="%s">', $meta_title );
            }
    
            if ( $meta_desc ) {
                printf( '<meta name="description" content="%s">', $meta_desc );
            }
        }
    } );
    #1285317
    Ricardo

    Thanks a lot!

    You and your team are very kind. If you ever need guitar lessons, I’ll be glad to offer you.

    May I assume that in terms of performance and stability (no need to update plugin) this can be better than a SEO plugin?

    Best regards,
    Ricardo

    #1285986
    Tom
    Lead Developer
    Lead Developer

    No problem!

    Performance-wise, it’s way better than an SEO plugin. However, those plugins do a lot more than just add meta titles/descriptions to your site, so functionality-wise it’s not even close.

    We use Yoast here on this website. Rank Math is also worth checking out if you want to do some performance tests.

    #1286041
    Ricardo

    Hi,

    I know those plugins, but for a specific project I just need to edit the meta description and title, so why using them?

    once again, thanks a lot!

    #1286511
    Tom
    Lead Developer
    Lead Developer

    That’s totally fair! In that case, custom fields are the way to go 🙂

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.