[Edit: I've added a more concrete example below]
I need to convert a custom PHP site to WordPress. The site has 60,000+ media items along with a ton of metadata, all of which needs to carry over to the new site. The media data is accessed via a local API and I've already figured out how to access the API in WordPress, so that's not a problem.
What I can't figure out is how to write a plugin so that
- the URL parameters determine what to show
(ideally via; andmod_rewrite
) - how and where to expose the plugin in WordPress.
In other words, how can I write a plugin so that the URLs /albums/12345
or /authors/23456
resolve to pages showing only the correct content?
I would be really happy for a simple RTFM, if you can tell me where in the documentation to look. It's been about 10 years since I last did anything with WP, so everything is pretty new to me now. I'm not even sure where to look.
Edit Here's a more concrete example:
Say I want to put up a constantly updating podcast feed from RSS, or a list of Tweets from the Twitter API or something like that. Basically the source is accessed by a well-defined API (and I can easily handle the logic to load, parse and format that stuff); the data is all there, ready for reading.
What do I need to do to have that content show up in response to specific URL requests?
For example, if someone goes to /podcasts/pages/1
, how do I make the page content show the first page of podcast titles. And if they go to /podcasts/items/oct-31-2015-wordpress
, how do I get the podcast metadata to show up?
Do I use an action or filter? What hooks do I need to use? Do I use a custom post type instead?
add_rewrite_rule()
might help here, though I'm not sure what you're looking for specifically. A more detailed example might help others answering this? Here's an article in the Codex on how to write a plugin if that helps regarding part 2.add_rewrite_endpoint()
. Just remember to flush the rewrite rules (they're stored in the database) when testing theadd_rewrite_*
functions, e.g. by visiting the Permalinks settings page.