• I wonder if anyone has some good advice for me:

    I have aprox 1000 names in a custom table in my database.
    Each name has between 1 and 100 separate elements also stored in a separate table.

    I need to be able to present the data in my WordPress installation, like individual URLs, like this:

    [my-site]/some-name-1/some-element-1
    [my-site]/some-name-1/some-element-2
    [my-site]/some-name-1/some-element-3

    [my-site]/some-name-2/some-element-1
    [my-site]/some-name-2/some-element-2

    and so on.

    So that I can link directly to an element belonging to a specific name.

    The names and elements are being changed and updated on a regular basis in the database – so I cant hardcode names and elements.

    I know how to create a smple WordPress-plugin – but I am not sure about how to go about this, since I obviously cant create pages for all of the names and elements.

    The important thing is the URL.
    It has to be: [site]/name/element

    There are other (regular pages) on the site.

    Does anybody here have any good advice?

Viewing 1 replies (of 1 total)
  • Hi,

    I am just thinking of the top of my head here and this may not be complete.

    But part of the puzzle is this:

    https://codex.www.ads-software.com/Function_Reference/wp_insert_post

    This function allows you to create posts and pages programmatically and specify the slug using

    ‘post_name’ => [ <string> ] // The name (slug) for your post

    Another part of the puzzle is this:

    https://codex.www.ads-software.com/Class_Reference/wpdb

    This allows you to get any data out of a database.

    So what you could do is use wpdb to get the name and element out of the database and then use wp_insert_post to create the page, including the slug.

    If instead of:

    [my-site]/some-name-1/some-element-1

    you can use:

    [my-site]/some-name-1-some-element-1

    then you can specify this slug in wp_insert_post…..

    Hope this helps ??

Viewing 1 replies (of 1 total)
  • The topic ‘dynamically generated urls / pages’ is closed to new replies.