Tag Info

Hot answers tagged

2

As you guess that's what happening(at least I think). You should separate your ajax logic from your "first load" logic. You can make a function ie my_get_posts that will be called inside archive-work.php and then inside ajax_filter_get_posts you can call the my_get_posts() function. archive-work.php <div class="work-results"> ...


2

Previous Question That answer I've linked to shows the steps you'll need to take. It probably didn't come up in your searches as you weren't using the right terms. As you're a front-end dev, this is how I'd do it based on that persons advice. Don't load anything in the template. Just have an empty ul with an id you can target, and a button to use for the ...


1

Each time you're making an ajax call, $_TEST = 0; is being evaluated again. You use the options API to manipulate your variable. function get_global_val() { $count = get_option( 'mycount' ); $count++; //or whatever you want to do with it update_option( 'mycount', $count ); die("New value is $count"); }


1

WP_Query has a $post_count variable. http://codex.wordpress.org/Class_Reference/WP_Query#Properties Just pass that with the script using wp_localize_script


1

I think that your problem is ajaxurl is not available for your script. Try to defined that varibale before your js code is loaded. The best way is using wp_localize_script: The PHP: add_action( 'wp_enqueue_scripts', 'cyb_enqueue_scripts' ); function cyb_enqueue_scripts() { //Change the key and url with yours wp_register_script('my-js', ...



Only top voted, non community-wiki answers of a minimum length are eligible