Help with customising love it plugin (use within foreach)

A couple of problems- setup_postdata doesn’t work with any variable other than $post, so that line is doing nothing. This is explained on the Codex page for setup_postdata. get_the_ID doesn’t accept any arguments, but it doesn’t matter, you’ve already got the ID in $event->ID, just change all instances of get_the_ID($event->ID) to $event->ID.

admin-ajax.php not working properly on subdomains

Don’t bother with the complicated cookie/ajax nonsense, use a REST API! We’ll use dependency injection and RESTful APIs to remove the cookies and simplify your AJAX code. First things first, lets turn this into a REST API: class Stuff { public function __construct() { add_action( ‘rest_api_init’, function () { register_rest_route( ‘soothsayer/v1’, ‘/current_rate/’, array( ‘methods’ => … Read more

How to pull data from a table using wpdb?

First, you want to use the global $wpdb variable. global $wbdp; Then set up your query. Make it a separate variable so you can output it and check for syntax errors. $my_query = $wpdb->prepare( /* SQL query here */ ); Then execute the query. $results = $wpdb->get_results( $my_query );

Display post thumbnail after clicking on post id with AJAX

You can start by trying this. 1. Change this <span class=”id_53″>Display Post Image</span> to <span class=”id_53″ data-id=”53″>Display Post Image</span> 2. Create you js file $(function () { // click event example $(‘.id_53’).on(‘click’, getThumb); // call the ajax function getThumb() { $.post( ‘http://path/wp-content/themes/your-theme/ajax-file.php’ , ‘my_id=’+$(this).attr(‘data-id’) , showThumb ); } // get image source function showThumb(e) { … Read more

Order & Orderby clause not working with custom query

Sorting your posts by relevance. The code below will output the posts ordered by relevance I have added some comments for some clarification let me know if it works. function my_custom_query(){ // get only the posts without order them $my_query_posts = new WP_Query( array( ‘numberposts’ => 5 ) ); // check relevance posts foreach( $my_query_posts->posts … Read more

How to manually define the primary loop

WordPress is not the solution to world hunger, global warming, and not even a good tool to create a one page apps in. If that is what you need, there are probably much better tools that will give you a much better ROI. In theory you can use wordpress as an API, creating an “headless” … Read more