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

Any method to make specific widget for every post and page?

You should be able to do what you want with the Category Country Aware (CCA) Plugin. (it’s for use within post/page content but also includes the widget below). Option 1: (only for posts and if you are happy to create one off categories): Create new categories for say “Washington” and “NY” via WP Admin Dashboard … 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.

how to call other plugins once custom post has been inserted

I don’t completely understand your question – maybe this will help: wp_insert_post(array( // your woocomm post being inserted )); // at insert, `save_post` will fire add_action( ‘save_post’, ‘my_plugin_save_post’ , 10 , 3 ); function my_plugin_save_post($post_id, $post, $update) { // check other firing of this: if this is a revision, get real post ID if ( … Read more

custom field – changing an element or background of id div – different versions not working

In most themes anything added via the wp_head hook should appear after (and override) enqueued CSS. So you could add an action to the themes functions.php and use get_queried_object_id() for the post ID. function my_dynamic_css() { $custombg = get_post_meta( get_queried_object_id(), ‘custombg’, true ); if (! empty($custombg)) { ?><style>#Box2 {background: <?php echo $custombg; ?> }</style> <?php … Read more

How to create a sub-page of sub-page?

I may be completely misunderstanding your question but I think you’re trying to create something like the image below. Correct? If that’s the case you would create the menu structure either using the “Customize” or the “Menu” option in the “Appearance” menu in WordPress. The you simply arrange menu items the way you want them … Read more

How to sort (orderby) a query done by a template function before the ‘foreach’ loop?

Without knowing what Realia_Post_Type_Property::get_properties() does and returns, this is a bit tricky to answer. But essentially, you want to to sort an array using PHP. Unless Realia_Post_Type_Property::get_properties() allows you to get a sorted list of posts, your best bet is probably to use wp_list_sort(). That function sorts a list of objects, based on one or … Read more