Custom url path with no post basis is considered as error

I have just tried the assignment settings for single layouts. I might need them for a page where no posts or archives are to be used as a basis, but these results are to be created dynamically in Cornerstone from a new API source.

And this seems to work quite well as you can see from the screenshots:

screenshot_ 2024-04-18 um 15.23.30

The page is displayed, and even the URL parameters are output correctly.

screenshot_ 2024-04-18 um 15.25.27

The only drawback is that the page is actually categorised as error404 although it actually works! This can be seen in the browser header as “Page not found” and the body class is also given as error404.

screenshot_ 2024-04-18 um 15.16.42

Would it be possible that this would not lead to an error404 classification of the page, because it would fit perfectly for my API interface. It would be another power feature for pro.

Thanks in advance

Hey @Regnalf,

Thanks for writing in! WordPress will always return an error 404 if the page does not exist. You should create a page named “_xPath” to prevent the error 404 messages.

Best Regards.

I think you misunderstood me here. I am not getting a 404 error message!.If I use a path that does not have an existing post or archive and is not catched by the Cornerstone layout logic, yes then I get a real 404 error or if I use theme.co’s custom error page then this one.

It’s not a bug, it’s a feature :smile:

But I get the content that I have defined in Cornerstone only as a layout. Which I think is wonderful, because it opens up new possibilities for defining paths without a post.
This generated page is only declared as a 404 error although it actually works perfectly. The error404 class in the body tag could still be ignored, but the message in the tab window “Page not found” is simply unattractive.

The best thing about it all is that even more dynamic combined values can be queried. For example, the following condition:

{{dc:url:segment index="0"}} is _date and
{{dc:url:segment index="1"}} is {{dc:global:date format="Ymd"}}

And you get something like this:

screenshot_ 2024-04-21 um 21.00.47

simply marvellous!

To show this functionality a bit more on a real world example is that I could use it for a golf club that loads tournament lists via an XML API interface. The individual tournaments could also be queried via this interface and I could retrieve the information about a single tournament with the following URL.

golfclub.tld/tournament/214

where 214 is the number for the single tournament. So I would have the individual tournaments like pages with their own URL without them having to be available as real post entries.

I have sent you two links and the access data to demonstrate this. So please, maybe there is a way to use this wonderful feature without this little cosmetic bug.

I couldn’t figure this out quickly for you, but you probably want to fake the request as another page so you don’t have the Page Not Found in the title. This would be a cool idea though. It would be nice too if you could only output the content and not even add HTML body stuff for a custom JSON api. I can add a feature request for you. Have a great day.

Thank you @charlie for picking up on the idea. I think with the add_rewrite_rule it would at least be a start, although as a temporary solution I am more with @ruenel solution to create a page and then call it with parameters.

like: golfclub.tld/page-tournaments?nr=214

It’s just a pity because it already works technically. Just with the above-mentioned flaw. But the possibilities are simply too tempting.

1 Like

You are most welcome, @Regnalf.