how to create endpoint for downloading pdf files?

A good action to hook in would be template_redirect. There you can query for your endpoint like this: add_action(‘template_redirect’, function() { global $wp_query; // Not your endpoint and not a page/post, we do nothing. if (!isset( $wp_query->query_vars[‘download’]) || ! is_singular()) { return; } // Here goes your magic! […] // And probably a good idea … Read more

Creating an endpoint in wordpress

You can create a custom endpoint using the add_feed function. I have used this in the past to create custom iCal feeds. // Initialize the feed function your_add_custom_feed() { // This adds a feed http://example.com/?feed=myfeed add_feed(‘myfeed’, ‘your_create_feed’); } add_action(‘init’,’your_add_custom_feed’); // Create a function to form the output function your_create_feed() { // Query variables are accessible … Read more

“rest_no_route” – Debug error

You should not GET on a POST only rest callback. The code below creates a POST call only register_rest_route(‘miningRigs/v1’, ‘createRig’, array( ‘methods’ => WP_REST_SERVER::CREATABLE, ‘callback’ => ‘createMiningRig’, )); Check http://localhost/wordpress-site/wp-json/miningRigs/v1 which shows you can only POST on createRig I just copy/paste you code + added the https://pressupinc.com/blog/2013/07/minimum-viable-wordpress-plugin/ then enabled the plugin on 4.9.5 and it … Read more

How to force Authentication on REST API for Password protected page using custom table and fetch() without Plugin

After studying carefully 🤓 the WordPress REST API Handbook concerning Home / REST API Handbook / Extending the REST API / Routes and Endpoints Home / REST API Handbook / Extending the REST API / Adding Custom Endpoints I realized I made a couple of mistakes. Therefore, I wanted to share with you my findings. … Read more

register_rest_field for custom taxonomy fields that are assosiated with custom post type

Both callbacks in the register_rest_field_for_custom_taxonomy_location() function are misspelled. change ‘get_callback’ => ‘location_get_term_meta’, ‘update_callback’ => ‘location_update_term_meta’, to ‘get_callback’ => ‘location_get_term_meta_field’, ‘update_callback’ => ‘location_update_term_meta_field’, Register Code function register_rest_field_for_custom_taxonomy_location() { register_rest_field( ‘location’, ‘location_code’, array( ‘get_callback’ => ‘location_get_term_meta_field’, ‘update_callback’ => ‘location_update_term_meta_field’, ‘schema’ => null, ) );

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)