Sql formatting for post data within function

It isn’t showing wp_posts.post_content LIKE ‘%test%’ because the wildcards (%) in the prepared statement are converted to placeholder escape strings (like the {a19f0a6c3d866f7270be0f3954cbb2600270400c15f488e112449a8a131701f0} in your post) when wpdb::prepare() calls wpdb::add_placeholder_escape() which “Adds a placeholder escape string, to escape anything that resembles a printf() placeholder“, i.e. a placeholder like %s. But those placeholder escape strings will … Read more

Upload data from weather station to WordPress Website

This is a pretty good application of WordPress’s REST API, which would enable you to update the data via a POST request containing the new data in JSON format and poll for changes with GET requests to the same endpoint. While you could establish this functionality with traditional AJAX request handlers, I think it makes … Read more

Loading dynamic content with AJAX breaking jQuery

So if you say there are no errors, I’m assumming that your problem is the AJAX request changing the DOM, and your scripts being loaded before that. If the document changes, you’ll need to tell your scripts that, so they will fire their events on the new content. So: Either you reload all scripts again … Read more

AJAX wp-mysql running too slow

When you call the database directly rather then using the $wpdb object its faster for a simple reason which is you only call the database, and the when you use $wpdb it loads extra functions and basically most of WordPress before you can use the $wpdb object. What you should try is to use the … Read more

jQuery tabs plugin with callback to fetch data

You can always use the proper WordPress Ajax API (well not really an api) for example: <li><a href=”https://wordpress.stackexchange.com/questions/25857/url to wp-admin/admin-ajax.php?action=my_ajax_tabs&tab=tab1″>Tab 1</a></li> <li><a href=”url to wp-admin/admin-ajax.php?action=my_ajax_tabs&tab=tab2″>Tab 2</a></li> then you create a function that will respond to the ajax calls: function do_my_tabs(){ $tab = $_GET[‘tab’]; switch ($tab){ case “tab1”: echo ‘tab1 content’; break; case “tab2”: echo ‘tab2 … Read more

Properly embed javascript into WP (using function.php) – doesn’t work?

By default, the jQuery script is loaded in no conflict mode. I noticed that you have in you header.php the following code: <script type=”text/javascript” src=”https://wordpress.stackexchange.com/questions/27986/<?php bloginfo(“template_directory’); ?>/js/jquery-1.4.2.min.js”></script> Adding jQuery like this, will override (if the page works) the wp_enqueue_script(‘jquery’). If you load jQuery like this, you need to activate the noConflict mode, as explained here. … Read more

blocking the admin section (but still using admin-ajax.php)

The following action hook should help: add_action(‘admin_init’, ‘wpse28702_restrictAdminAccess’, 1); function wpse28702_restrictAdminAccess() { $isAjax = (defined(‘DOING_AJAX’) && true === DOING_AJAX) ? true : false; if(!$isAjax) { if(!current_user_can(‘administrator’)) { wp_die(__(‘You are not allowed to access this part of the site’)); } } }

Post will not load via ajax

All ajax requests should be routed through the handy /wp-admin/admin-ajax.php file. It works with the great WP hooks system. So you send an “action” with your request and use that as part of the action into which you hook your function. So, let’s say your ajax call looks like this (with jQuery) jQuery(‘a.ajax’).click(function(e){ data = … Read more