Edent,
@Edent@mastodon.social avatar

I'm being a bit thick with .

Given an arbitrary URl on my blog - how can I get the query which it would execute?

If you've a mind to help - https://wordpress.stackexchange.com/questions/425043/equivalent-of-url-to-postid-for-non-post-urls - much appreciated!

otto42,
@otto42@fosstodon.org avatar

@Edent you have to run the rewrite_rules against the URL in order to determine what it's going to query for.

Edent,
@Edent@mastodon.social avatar

@otto42 ah, I see. I'll take a look. Thanks.

otto42,
@otto42@fosstodon.org avatar

@Edent generally though, you don't have to do that because you can hook in later and it's already run that against the URL and it has already done it for you. What exactly are you trying to do, and how are you trying to do it?

Edent,
@Edent@mastodon.social avatar

@otto42
If someone requests /blog/post123_ABC I want to get the data for /blog/post123

That is, if the request 404s in a very specific way - I'm going to trim the end off, and get the page without the extra _ABC.

otto42,
@otto42@fosstodon.org avatar

@Edent is there anything special about the URL "post123_ABC"? Was the slug used before or something like that?

Edent,
@Edent@mastodon.social avatar

@otto42 No.
Basically, if someone requests a page with .xml or .md or .txt at the end, I want to serve up that page with in that format.

I have it working for individual posts, but not for tags, categories, dates, etc.

mattround,
@mattround@crispsandwi.ch avatar

@Edent @otto42 Could you add/modify an htaccess rewrite rule that puts the extra extension into query string, then retrieve it later to adjust output?

Edent,
@Edent@mastodon.social avatar

@mattround @otto42
That's probably the sensible way to do it.

But I've found something much more convoluted 😆

gadgetoid,
@gadgetoid@fosstodon.org avatar

@Edent afaik the query is entirely arbitrary because it’s governed by whatever template handles that page, rather than any internally consistent logic?

Edent,
@Edent@mastodon.social avatar

@gadgetoid maybe that's where I'm going wrong? I'm trying to use a sub-template which doesn't receive any information about the page which is rendering it.
I may well do doing something very stupid 😆

gadgetoid,
@gadgetoid@fosstodon.org avatar

@Edent oh so you’ve got the URL but nothing else to work with inside your template context? It’s been a looong time since I messed with my templates but afaik you get querystring parameters and the implicit scope that a given template is usually mapped to a given section?

What even is a sub template? 🤣 my theme is 17 years old at this point.

Edent,
@Edent@mastodon.social avatar

@gadgetoid yeah. I'm hacking together something abhorrent 🙂

  • All
  • Subscribed
  • Moderated
  • Favorites
  • wordpress
  • DreamBathrooms
  • ngwrru68w68
  • modclub
  • magazineikmin
  • thenastyranch
  • rosin
  • khanakhh
  • InstantRegret
  • Youngstown
  • slotface
  • Durango
  • kavyap
  • mdbf
  • GTA5RPClips
  • provamag3
  • ethstaker
  • normalnudes
  • tester
  • osvaldo12
  • everett
  • cubers
  • tacticalgear
  • anitta
  • megavids
  • Leos
  • cisconetworking
  • JUstTest
  • lostlight
  • All magazines