wp_insert_post() is returning the correct post ID, no failure, but the post content does not get updated

Don’t bother fixing your AJAX callback, there’s already a REST API endpoint that’s well tested and does all of this out of the box: example.com/wp-json/wp/v2/zen_page So lets enqueue a helper script to give us the URL and a security token/nonce: wp_enqueue_script( ‘wp-api’ ); You will must enable the REST API for your custom post type … Read more

wp-load Without Loading the plugins

You would need to put something like this in a .php file of any name in your must-use plugins folder (/wp-content/mu-plugins/) so that it loads before all plugins so you can use it to filter the plugin loading… <?php if (defined(‘SHORTINIT’) && SHORTINIT) { add_filter(‘option_active_plugins’, ‘shortinit_plugins_filter’); function shortinit_plugins_filter($plugins) { $noloadplugins = array(‘w3-total-cache’); foreach ($plugins as … Read more

Link for Most Recent Post

You’ll need to use get_posts() to get the latest post, then pass it to get_the_permalink() to get the URL to it: <?php $latest_posts = get_posts( array( ‘numberposts’ => 1 ) ); if ( ! empty( $latest_posts ) ) : $latest_post = $latest_posts[0]; if ( $latest_post->ID !== get_the_ID() ) : ?> <a href=”https://wordpress.stackexchange.com/questions/284553/<?php echo get_the_permalink( $latest_post … Read more

How to Fetch values from WP database based on selected option value by onchange using PHP?

You can use below example to use Ajax in wordpress. This article explains it quite nicely. Main jquery function to use wp_enqueue_script( ‘ajax-scripts’, url-to-your-file/plugin-ajax.js’, __FILE__ ) , array( ‘jquery’ ), ‘1.0.0’, true ); jQuery(function($) { $(document).ready(function(){ $(‘#mySelect’).on( ‘change’ , function(){ var newValue = $(this).val(); $.ajax({ type: ‘POST’, url: ajaxurl, // use ajax_params.ajax_url if using in … Read more

Calculations in functions.php [closed]

On those lines get_post_meta() will return an array because by default the third argument of get_post_meta() is false. If you want to return a single value you should call it like so: get_post_meta( get_the_ID(), ‘invoice_service_amount’, true ); Additionally, you may want to get the post meta first and then ensure you have a value (wrapping … Read more