Add Condition if WPBakery Page Builder Used on Page or Not

Some quick answer you can achieve what you want to do. There is a filter which check if the current page post type is available for using WPBaker called `vc_is_valid_post_type_be’ and there you can manage “can” or “cannot” to load it. add_filter(‘vc_is_valid_post_type_be’, ‘wpse308043_vc_is_valid_post_type_be’, 10, 2); function wpse308043_vc_is_valid_post_type_be($checked_type, $type) { global $post; if($post->ID == 106) return … Read more

How can I re-use PHP code across different pages?

You’re looking for something similar to PHPs require or include function. In WordPress we can use get_template_part( ‘example-folder/template’ ); to get template.php from the example-folder. You should also look into the get_template_part function to see the capabilities. If you’re wanting to include outside variables into these, you can use PHP globals.

How to print array of specific item

Not really a WordPress question, but I’ll bite. That data is JSON. To manipulate it with PHP you need to decode it with json_decode(). Then you can treat it as a PHP object. So to access the values you’d mention, and assuming the JSON is in a variable named $json: $object = json_decode( $json ); … Read more

ACF: Echo page title when checkbox is checked

You would like to use ACF true/false field > link Then basically in your template wrap the title element in conditional, like this: if( get_field( ‘title_show_or_whatever’ ) ) { // The title element }

WooCommerce Custom Pagination

Hope you are doing good. You can use the below sample code: Updated: I have updated my Gist link to added code of template. Create a template with name template-product.php <?php /** * @author Baikare Sandeep * * Template Name: Product */ get_header(); ?> <?php $args = array( ‘posts_per_page’=> 12, ‘post_type’ => ‘product’, ‘post_status’ => … Read more

Cross origin ajax request always returns 0 when calling get_current_user_id();

Don’t write your own bootstrapper, use Ajax hooks via wp-admin/admin-ajax.php Documentation: https://codex.wordpress.org/AJAX_in_Plugins Then you can be sure WordPress has included all the functions you need. Update: I missed the bit about posting from local machine to remote server. If your JavaScript is running on another domain, it won’t be sending back your web server’s login … Read more

Adding Gravity Form With if(is_page) Is Not Working

if you got following in your functions.php function add_split_test_forms() { if (is_page(‘Homepage’)): gravity_form(19, false, false, false, ”, false); endif; } you will at least need to run this function once: add a line add_split_test_forms() in your functions.php. if your condition if (is_page(‘Homepage’)): is correct. (I prefer if ( is_front_page()): should also work.) Then your form … Read more

static array on functions.php

This is a good use case for the Object Cache: WP_Object_Cache is WordPress’ class for caching data which may be computationally expensive to regenerate, such as the result of complex database queries. You can store things in the cache with wp_cache_set() and retrieve them with wp_cache_get(). You just need to give it a key and … Read more

Create an unique ID number after submit form

in order to do this use AUTO_INCREMENT PRIMARY KEY while you define your table. Your table should be something like this: CREATE TABLE `order` ( `order_id` INT(11) UNSIGNED AUTO_INCREMENT PRIMARY KEY, `user_group_id` INT(11) UNSIGNED NOT NULL, `status` BIT, `meta` VARCHAR ( 255 ), `value` TEXT, `update_time` TIMESTAMP )DEFAULT CHARSET = utf8; remember that you could … Read more