How do I reformat this to add php inside php?

As PHP documentation says Often you’d want to have more than one statement to be executed conditionally. Of course, there’s no need to wrap each statement with an if clause. Instead, you can group several statements into a statement group. So You have to use curly braces {} to add more statement within if else … Read more

is_plugin_active() not defined on active plugin, in the thumbnails.php file

You can try this, it works for me 🙂 // We need plugin.php! require_once( ABSPATH . ‘wp-admin/includes/plugin.php’ ); $plugins = get_plugins(); foreach ($plugins as $key => $value) { if ( $value[‘Name’] == ‘Aest Plugins’ ) { // <– name plugin validate if( is_plugin_active( $key ) ){ echo “plugin {$value[‘Name’]} is active”; }else{ echo “plugin {$value[‘Name’]} … Read more

Display Sale Price Before Regular Price (WooCommerce)

You have to change this in functions.php if (!function_exists(‘my_commonPriceHtml’)) { function my_commonPriceHtml($price_amt, $regular_price, $sale_price) { $html_price=”<p class=”price”>”; //if product is in sale if (($price_amt == $sale_price) && ($sale_price != 0)) { $html_price .= ‘<ins>’ . wc_price($sale_price) . ‘</ins>’; $html_price .= ‘&nbsp;&nbsp;<del>’ . wc_price($regular_price) . ‘</del>’; } //in sale but free else if (($price_amt == $sale_price) … Read more

How to tweak a plugin without preventing it from updating

Create a plugin that dequeues the javascript you don’t want, and enqueues the edited javascript. <?php /** * Plugin Name: Stackexchange Sample * Author: Nathan Johnson * Licence: GPL2+ * Licence URI: https://www.gnu.org/licenses/gpl-2.0.en.html * Domain Path: /languages * Text Domain: stackexchange-sample */ //* Don’t access this file directly defined( ‘ABSPATH’ ) or die(); add_action( ‘wp_enqueue_scripts’, … Read more

Display popularpost posts of the last 2 days

in argument list please also pass date_query, try below example. $args = array( ‘posts_per_page’ => 10, ‘post_type’ => ‘post’, ‘order’ => ‘DESC’, ‘date_query’ => array( ‘after’ => ‘2 days ago’, ‘inclusive’ => true ) ); $posts = get_posts($args);

My title is showing after the shortcode

You needs to change buffer like this: <?php function shortcode_callback() { ob_start(); //my code here return ob_get_clean(); } add_shortcode(‘shortcode’, ‘shortcode_callback’); ?> Please check after replace ob_get_clean(); in your code with return ob_get_clean(); then it’s working fine.

Populate checkboxes from array

Use the following function to make check-boxes for taxonomies: function get_terms_chekboxes($taxonomies, $args) { $terms = get_terms($taxonomies, $args); foreach($terms as $term){ $output .= ‘<label for=”‘.$term->slug.'”><input type=”checkbox” id=”‘.$term->slug.'” name=”‘.$term->taxonomy.'” value=”‘.$term->slug.'”> ‘.$term->name.'</label>’; } return $output; } echo get_terms_chekboxes(‘country’, $args = array(‘hide_empty’=>true)); Hope this will help you!