• Hello to all!

    I need to automatize page creation process on WordPress website.

    I have a page with a title, content, permalink and some other attributes (like Social buttons plugin disabled/enabled, page template, comments allowed/disallowed etc.).

    Everything is static, but I have to change 1 variable word in title and content for each new page.

    Example:

    Title: My article about {VARIABLE}
    Content: Hello! Today we will talk about {VARIABLE}.

    So I need to automatize the process of page creation, for example, if I set variable to “coffee” and then generate such a page, it would be like this:

    Title: My article about coffee
    Content: Hello! Today we will talk about coffee.

    Any ideas how can I do that? Maybe a WordPress plugin? Or maybe SQL query to duplicate a page (preserving all the attributes) and change {VARIABLE} to a desired word?

    Thanks in advance!

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    Use wp_insert_post() to create new pages by script. Even though it’s intended for posts, pages work too since they are just another post type.

    The real question is how to specify what the variable value will be for a particular page and how to initiate the code. There’s a number of approaches, from the sounds of it, I’d suggest adding a admin sub-menu page with add_submenu_page(). All that’s required on the page is a text field for the variable value and a submit button.

    Pressing Submit posts the field value to the same page. It recognizes the POST request type and uses the posted value to assemble the data array used in wp_insert_post().

Viewing 1 replies (of 1 total)

The topic ‘Page creation automatization in WordPress’ is closed to new replies.