Current post in AJAX call is always zero

Replace your ajax code with this code. I didn’t check it but i think it should we working. The whole html part is convert into string so that it will send via ajax response. <?php global $post; $data = filter_var_array($_POST, FILTER_SANITIZE_SPECIAL_CHARS); if ($data[‘action’] == “timeline_load”) { $post = null; $args = array( ‘post_type’ => ‘timeline’, … Read more

How to get list of posts from permalinks?

There are several ways to achieve this, depending on the permalink structure of your posts. Assuming the post slug is part of the permalink structure, you can get the post slug from the post URL and fetch the corresponding post by using WP_Query with the name-parameter. Let’s assume the structure of the URLs is http://example.com/{post_slug}/. … Read more

Taxonomy and Date in same query?

Take a closer look at the date parameters; you’ll need to enter an integer (number), not a string (text). Simply get rid of the single quotes to make it work: $args = array( ‘post_type’ => ‘job’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘location’, ‘terms’ => ‘dallas’, ‘field’ => ‘slug’ ) ), ‘date_query’ => array( array( … Read more

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

WP_Delete_user link creation

WordPress does not provide delete user link as it provides for deleting posts. Therefore, we should do this using Ajax. Following would be the approach towards solving this issue: Add user id as attribute to a tag When anchor is clicked, get the user id and fire ajax request which would delete the user. Kindly, … Read more