• Hi!

    Can I use WordPress as a head for a headless backend?

    I need to create a routing system that passes paramaters to pages to display dynamic content. The URL should be nice, like any modern router supports.

    For example imagine I create a single page “Restaurant”.

    Then I want:

    Is this possible in a code-less fashion (either natively, or either with an open-sourced plugin)?

    Or I must create code to handle that (either in a snippets plugin or making my own plugin)?

    • This topic was modified 1 year, 1 month ago by xmontero.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    Dynamic content implies you’ll need code of some sort ?? It’s somewhat easier if the ID were passed as a query string:
    example.com/restaurant/?store=1234
    But you can add a custom rewrite rule that translates example.com/restaurant/1234/ to something WP understands like
    index.php?pagename=restaurant&store=1234

    The restaurant page could have custom code that uses the passed store ID to get the necessary data via an API, then it presents the returned data in a user friendly format.

    Because code like this needs to interact with a specific API, I’m skeptical you’ll find a suitable plugin already existing. I think you’ll likely need a custom theme or plugin for this.

    Thread Starter xmontero

    (@xmontero)

    Thanks @bcworkz,

    I guess this rewrite rule is at the level of the webserver (be it apache, nginx, or whatver)?

    Or it is “built-in” the wordpress itself?

    I mean: In the settings/permalinks there’s stuff regarding the rewriting of the URL for some standard setups.

    When you tell I should add a custom rewrite rule, do you mean at the apache level? Or somehow inside the wordpress itself?

    Thnx!

    Moderator bcworkz

    (@bcworkz)

    There are both server rewrites and WP rewrites. In this case I think either would work, but what I was thinking of was the WP kind using add_rewrite_rule(). An appropriate RedirectMatch directive or equivalent in .htaccess would likely achieve the same result.

    If you do use add_rewrite_rule(), after adding the code you will need to visit the permalinks settings admin screen to get it to take effect. No need to change or save anything, loading the screen is enough.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Code-less page to display entities from a remote source, with nice URL’ is closed to new replies.