• Resolved heinvv

    (@heinperu)


    I would like to copy data from two old websites to a new website.

    I’d like to know a few things:

    How can I add a title and description to a page programmatically using custom php?

    And the opposite question:
    And how can I read the current TSF title and description inside php?

Viewing 1 replies (of 1 total)
  • Plugin Author Sybre Waaijer

    (@cybr)

    Hello!

    To read the data, you can use function the_seo_framework(), which returns the façade god-object of The SEO Framework (when available). That object yields methods get_title() and get_description(). E.g. $title = the_seo_framework()->get_title();.

    To set a page title and description programmatically, you can use filters: https://tsf.fyi/docs/api/filters#title-related.

    To save one… as in, saving in the database… I’m not sure you should take over that control of TSF. Nevertheless, you can find the metadata keys here: https://tsf.fyi/kb/article/108#tsf-post. You may want to look into TSF’s method update_single_post_meta_item(); it makes sure the data gets where it should without causing corruption. Keep in mind that TSF adds the site name separately to the title.

    • This reply was modified 4 years, 8 months ago by Sybre Waaijer. Reason: clarity
Viewing 1 replies (of 1 total)

The topic ‘How to save a page title and description programatically’ is closed to new replies.