fix undefined variable in native wp files
fix undefined variable in native wp files
fix undefined variable in native wp files
You have the global WP_Post object available so you can look the post type like this: function wrap_post_images_to_div( $content ) { if ( get_post()->post_type === ‘post’ ) { $pattern = ‘/(<img([^>]*)>)/i’; $replacement=”<div class=”well text-center”>$1</div>”; $content = preg_replace( $pattern, $replacement, $content ); } return $content; } add_filter( ‘the_content’, ‘wrap_post_images_to_div’ ); You can use the preg_replace_callback instead … Read more
There are potentially many ways to achieve what you want to do. My approach would be to use WooCommerce and then define ‘Ford Focus’ as a product. I then would configure the product to offer the various different colors and/or any other features. This approach would not create 5 pages on the sitemap. It would … Read more
There’s an option in the wp_sitemeta table with meta_key ‘menu_items’ this value is referred to the checkbox “Administration menu” of the page /wp-admin/network/settings.php (accessible only to siteadmins) that allows the activation of plugins on single sites. I’ve not tested but using the value a:1:{s:7:”plugins”;s:1:”1″;} and having the plugin uploaded via ftp you should see the … Read more
How to display variables from plugin?
I managed to find the soulution: add_action(‘woocommerce_after_add_to_cart_button’, ‘wc_min_quantity’,10,2); function wc_min_quantity($product) { if(function_exists(‘icl_object_id’)) { $default_language = wpml_get_default_language(); $prodid = icl_object_id($product->get_id(), ‘product’, true, $default_language); } else { $prodid = $product->id; } $prodid = get_the_ID(); $minQty = get_post_meta($prodid, ‘_wc_mmax_min’, true); if ($minQty > 0) { } echo “Minimum order quantity: $minQty”; }
Managed to find the solution. My finished code is: register_activation_hook ( __FILE__, ‘cron_job’ ); function cron_job() { wp_schedule_event( time(), ‘hourly’, ‘hourly_job’ ); } add_action( ‘hourly_job’, ‘cron_job_task’ ); function cron_job_task () { $users = get_users( array( ‘fields’ => array( ‘ID’, ‘user_registered’ ), ‘role’ => ‘coaching’, ) ); foreach ( $users as $user ) { $time = … Read more
How can I refresh the plugins cache manually?
You could add a filter to the post publish process in site A. The filter would check for the tag/category, and if found, run a process to create a post in Site B. See https://codex.wordpress.org/Plugin_API/Action_Reference/save_post . Something like: add_action( ‘save_post’, ‘my_site_b_create_post’ ); function my_site_b_create_post($post_id) { // check for category // if category, then save content … Read more
I tried it step by step and finally succeeded. Step 1 – hello.py I tried to create the hello.py file with Atom on Windows 10 and uploaded it to a Linux server for many times. It could run with the “python3 hello.py” command, but always failed to run when using the “./hello.py” command. I had … Read more