How to get gallery id inserted to a post?

In single.php i put this code, from this link (thank you Wyck) https://stackoverflow.com/questions/14277794/wordpress-3-5-own-gallery-with-included-images-doesnt-work preg_match(‘/\/’, $post_content, $ids); $array_id = explode(“,”, $ids[1]); print_r($array_id); Now I can use gallery shortcode

Three level taxonomy dropdown frontend

After spending many hours using google I managed to make 3-level hierarchical taxonomy dropdown with ajax. Here is my code: searchform.php <script type=”text/javascript” src=”http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js” ></script> <script type=”text/javascript”> $(function(){ $(‘#apskritis’).change(function(){ var $apskritisSlug=$(‘#apskritis’).val(); // call ajax $(“#savivaldybe”).empty(); $(“#miestas_kaimas”).empty(); $.ajax({ url:”/wp-admin/admin-ajax.php”, type:’POST’, data:’action=get_savivaldybes&apskritis_slug=’ + $apskritisSlug, success:function(results) { //alert(results); $(“#savivaldybe”).removeAttr(“disabled”); $(“#savivaldybe”).append(results); } }); } ); $(‘#savivaldybe’).change(function(){ var $savivaldybeSlug=$(‘#savivaldybe’).val(); // … Read more

Load ajax if is_home()

Use: if ( is_home() or ( defined( ‘DOING_AJAX’ ) && DOING_AJAX ) ) is_home() returns TRUE on the front-end only, admin-ajax.php on the other hand is an admin page. So you need to check both conditions.

Using AJAX with Forms

Your add_action() calls for the AJAX handlers are too late. Add these hooks earlier, the best action is probably wp_loaded: add_action( ‘wp_loaded’, ‘register_ajax_handlers’ ); function register_ajax_handlers() { add_action( ‘wp_ajax_jp_ajax_request’, ‘jp_ajax_process’); add_action( ‘wp_ajax_nopriv_jp_ajax_request’, ‘jp_ajax_process’); } See also: Debug AJAX. This code should be placed in a plugin or in your theme’s functions.php.

Update Custom post field by Ajax on cached site

I’ve spotted some errors here: jQuery.ajax({ type: “POST”, contentType: “application/json; charset=utf-8”, // default: ‘application/x-www-form-urlencoded; charset=UTF-8’. you can not set url: “http://localhost/wp-admin/admin-ajax.php”, // if you have correctly enabled ajax in wp, you should use the object you set up with the url data: “{‘action’:’get_PostViews(” + idpost + “)’}”, // you can use a PlainObject notation, so … Read more

How to use several wp_ajax_ functions for different queries?

I was able to get multiple wp_ajax_ functions to declare callback functions like this: add_action( ‘init’, ‘my_ajax_init’ ); function my_ajax_init() { add_action(‘wp_ajax_nopriv_wpa56343_search’, ‘first_search’); add_action(‘wp_ajax_wpa56343_search’, ‘first_search’); } add_action( ‘init’, ‘my_ajax_no_geo_init’ ); function my_ajax_no_geo_init() { add_action(‘wp_ajax_nopriv_nogeo_results’, ‘second_search’); add_action(‘wp_ajax_nogeo_results’, ‘second_search’); }

WordPress Plugin Page is Loading in Admin Content Container Instead of Separate Page

I’ll preface this by saying I think it’s a really bad idea, but you could circumvent the admin UI by hooking an action that happens after things are initialized, but before any output occurs: function my_admin_ui(){ if( isset( $_GET[‘page’] ) && ‘myPlugin-ui’ == $_GET[‘page’] ){ include( plugin_dir_path( __FILE__ ) . ‘views/myPlugin-ui.php’ ); exit; } } … Read more

Using foreach inside an ajax function

Ok so it actually looks like there is a couple of ways you could do this. The first one is by changing your $list into an array and returning it as JSON. It will be easy to change $list to an array by just adding it like this: $list[] = ‘<option value=”‘.$term->term_id.'”>’.$term->name.'</option>’; Then return it … Read more

Using ajax with wordpress

In WordPress Ajax works this way: First, you register the ajax action and the function you want to use to serve that action, of course, you have to write that function. All the request go to the same URL wp-admin/admin-ajax.php, what it changes is the action, and depending on the action, a different function is … Read more