Date of last blog update for specific authors only?

Ok, Paul, So I took a few minutes to figure this out (assuming this is where you’re going with this): Here’s the MySQL query that will give you the latest post date, one user at a time: SELECT post_date FROM wp_posts WHERE post_author = 1066 ORDER BY post_date DESC LIMIT 1 (The number “1066” is … Read more

WooCommerce – Add Shipping class below each product in Shopping Cart page

You can try using a custom function hooked in woocommerce_cart_item_name filter hook, this way: add_filter( ‘woocommerce_cart_item_name’, ‘shipping_class_in_item_name’, 20, 3); function shipping_class_in_item_name( $item_name, $cart_item, $cart_item_key ) { // Only in cart page (remove the line below to allow the display in checkout too) if( ! ( is_cart() || is_checkout() ) ) return $item_name; $product = $cart_item[‘data’]; … Read more

How does WordPress rewrite URLS using its PHP scripts

WordPress can make redirects internally, by wp_redirect() function. It is php code, for it to function, no redirect in Apache (httpd) or Nginx web server is needed. Also, WordPress has own rewrite API, accessible via add_rewrite_rule() and similar functions. This is also php code, which doesn’t require any support from a web server.

Custom WordPress Core upgrade through wp-cli

This is a php script that can execute wp-cli, Keep the file in wp-admin/ folder and visit www.example-wordpress.com/wp-admin/execute_cli.php to run the script. This is just for test purposes and not a good way to use. execute_cli.php <?php error_reporting(E_ALL | E_STRICT); ini_set(‘display_errors’, ‘1’); echo “<PRE>\n”; if(!defined(‘STDIN’)) define(‘STDIN’, fopen(‘php://stdin’, ‘r’)); if(!defined(‘STDOUT’)) define(‘STDOUT’, fopen(‘php://stdout’, ‘w’)); if(!defined(‘STDERR’)) define(‘STDERR’, fopen(‘php://stdout’, … Read more

dynamically change content of div with php

If you were to localize admin-ajax.php then if you add these functions to functions.php: add_action( ‘wp_ajax_nopriv_create_posts’, ‘my_create_posts’ ); add_action( ‘wp_ajax_create_posts’, ‘my_create_posts’ ); function my_create_posts(){ if (is_string($_POST[‘a’])) {   $name = $_POST[‘a’];   //echo $name; and soo on… } } The ‘action’ in the ajax call is needed for defining to which ajax call to pair your function, … Read more

Add wp posts to cutom masonry grid

Instead of $count == 1 you should use ($count % 12) == 0, 1, and so on till 11. This gives back the remaining of the division. So if $count is 6 you would get 6, but if $count was 16 it would give back 4.