Ajax call returning 0

When defining an Ajax handler, you should consider defining both for logged in and non logged in users. You can do so by using: add_action(‘wp_ajax_my_handler’, ‘callback_function’); add_action(‘wp_ajax_nopriv_my_handler’, ‘callback_function’); Now, as for your question. We can turn this code into a REST endpoint, if you are interested, which is faster and easier to set up. Let’s … Read more

How can I make my metabox appear?

I’ve managed to make it work because of @howdy_mcGee’s comment. I did not notice that I had to call the specific post type name of it. my code is now like this and it shows up! function slide_add_post_meta_boxes() { add_meta_box( ‘pukkemukslideshow’, // Unique ID __( ‘Slideshow’, ‘example’ ), // Title ‘slide_post_class_meta_box’, // Callback function ‘slideshow’, … Read more

Insert content of a post into another

When you use return in your function, the rest of the function will not run. It work somehow like exit(); or die();, but it won’t terminate the entire script, only ends that particular piece of code in your function, and return a value if necessary. You should save your content into a string, and then … Read more

Use of Templates in a Plugin

You would need to add a filter to the page_template hook that will look for whatever criteria you need. For example, if your plugin was for a custom post type you would have something like this: function myCustomTemplate( $page_template ) { // Check theme for template file $located = locate_template( ‘single-{{postype}}’ ); if ( ! … Read more