A
A
Alexander2015-12-01 17:06:08
WordPress
Alexander, 2015-12-01 17:06:08

How to attach custom PHP handler in WordPress?

Good day to all and good luck!!!
I have a WordPress site and everything works well.
Task:
I want to connect a post handler. Type:

wp_header();
// мой обработчик
wp_footer();

Conditions:
If the link is like site.com/post/ochen-horoshiy-post-2015/, then my handler should not interfere and WordPress itself issues a post from its database.
And if the type link is site.com/special-posts/custom-post-2015/, then my handler should turn on, which will receive the "custom-post-2015" parameter and issue the necessary post, in the site design and not from the WordPress database (t .e. intercept the CNC) and not generate a 404 error.
How should my handler be included if the link contains "special-posts"
How to implement it: on a plugin, on a filter, on hooks ??? How ?
Updated:
I went about creating a page template. Created, named, the handler is enabled, everything is OK - site.com/special-posts
But as soon as the link contains a tail - "/custom-post-2015/", then 404 is triggered.
If I'm on the right track, tell me how to intercept (or prevent) the 404 handler in such cases?
ReUpdated:
The solution was found: I added a cnc rewrite rule, created a page template and in the template my handler does what he wants.
Thank you all for your replies)))

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question