• mohamedh

    (@mohamedh)


    Hi there

    I am working on a plugin for WP.

    Context:
    – A blog for fictional characters. Every character has a page example.com/character/some_name
    – Every character belongs to a category (Earth, fire, water, etc)
    – Blog authors add a new character to the DB via a form on wp-admin, they fill in some fields and it is added to the DB (and a new ID is generated).

    So far, I have started my work and for each new character added
    the plugin creates a new WordPress page that contains the shortcode [myplugin char-id=some_int] of our plugin to fetch character info from the database and that page has a category (one from the categories I mentioned above).

    I was wondering if any experienced plugin authors have suggestions on good practices for doing this?

    First of all, is it a good idea to create a new page for every character that only has a shortcode in the body + a category + character name as the title page? this will spam our WP database with lots of pages, so I am thinking it is better to find a way to read some identifiers from the URL? example example.com/character?name=some_name and use $_GET or something that looks a bit fancier with the same logic?

    Secondly, right now we rely on native categories of WP, so if the user wants to see “fire” characters they click the link and voila, but the problem is, these are confused with categories of regular blog posts/news, the alternative would be to manually implement the listing by category to do the query directly to my extra Table for characters. Another advantage of the current approach, since there is a page with every character’s name, when a user types the name in the native blog’s search bar, the page shows up!

    are there any common/good practices that people usually follow in these scenarios?

    Assuming a site like IMDB, MyanimeList, etc are built using WP, how would such a use-case be implemented?

    Thanks

  • The topic ‘Creating pages with shortcode Vs fetching from DB directly in 1 page’ is closed to new replies.