I
I
IgorKornejchuk2016-03-25 13:56:27
WordPress
IgorKornejchuk, 2016-03-25 13:56:27

How to make an output in WordPress without a template?

I make in the plugin the function of answering the server by url of the form: /?wc-api=wc_plugin&action=success The
question is that the server needs to respond only in XML. Accordingly, you need to draw a conclusion by disabling the output of the WP template.
In Joomla, there is a ?format=raw parameter for this, in WP I didn’t find something similar.
I found about setting up an empty template for this kind of addresses, but I would not like to supply a plugin with instructions for modifying templates :)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2016-03-25
@IgorKornejchuk

several options:
1 add your custom endpoint via the Rewrite API
you can catch requests like site.ru/wc-api/...
2 use admin-ajax.php as an entry point to
send requests to site.ru/wp-admin/admin-ajax .php?action=wc-api...
3 use a custom route for the REST API
something like this site.ru/wp-json/wc-api/...
4 add a filter to page_template or something similar
replace the template page to the right one, if isset($_GET['wc-api']) && $_GET['wc-api']=='
wc_plugin
' -api']) && $_GET['wc-api']=='wc_plugin' and access like this
site.ru/hello-world/feed/?wc-api...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question