Plugins not working on AJAX requests

//This is the function that fails when calling the function via an AJAX request. $context[‘stories’] = apply_filters(‘xfwpint_get_slider_post_data’, $context[‘stories’]); When calling via ajax , you have to include file in your ajax action function, file in which you have defined your filter, so it gets called. For e.g. require_once(‘./my_file_containing_filter_function’);

Using AJAX to generate front end / viewer end pages

Your are pointing to a non existing AJAX file. $.ajax( { // … url : ‘/path/myfile.php’, // … } ); WordPress has a predefined file for that: admin_url( ‘admin-ajax.php’ ) When you are running public queries, then you need to add it to wp_localize_script( ‘your-script-handle’, ‘yourJavaScriptAccessibleObject’, array( ‘ajaxurl’ => esc_js( admin_url( ‘admin-ajax.php’ ) ), ) … Read more

Using WP_Query to grab custom meta values, foreach to json object

The best way to go about this is with $wpdb. The query to draw out meta_value by category is: $query = $wpdb->get_results( “SELECT p.`ID`, pm.`meta_value` FROM {$wpdb->postmeta} pm LEFT JOIN {$wpdb->posts} `p` ON `p`.`ID` = pm.`post_id` LEFT JOIN {$wpdb->term_relationships} `tr` ON `p`.`ID` = `tr`.`object_id` LEFT JOIN {$wpdb->term_taxonomy} `tt` ON `tr`.`term_taxonomy_id` = `tt`.`term_taxonomy_id` WHERE `pm`.`meta_key` = … Read more

WP http XML response HTML encoding and image display problems

Registering dependencies WordPress uses the Dependency API for that. It’s fairly simple: Register & enqueue a script, then pass data that you want to pass from WP/PHP to JS using wp_localize_script(), which adds a <script> tag containing an Array to your DOM (exactly before your script gets added to it): add_action( ‘wp_enqueue_scripts’, function() { $name=”handle”; … Read more