Get shortcode attribute value to another function

<?php class MakeShortcode { public $color; public function __construct() { add_action( ‘init’, array($this, ‘PostBLock’) ); add_shortcode( ‘PostBLock’, array($this, ‘getpostblock’) ); add_action( ‘wp_enqueue_scripts’, array( $this, ‘inlinestyle’) ); } public function getpostblock( $atts ){ extract( shortcode_atts( array( ‘section_color’ => ‘#000000’, ), $atts) ); return $section_color; } public function inlinestyle(){ $color = $this->getpostblock(); wp_enqueue_style( ‘custom-style’, get_template_directory_uri() . ‘/css/style.css’ … Read more

Show number of sold products but be first for less than 2

OK, so if anyone else is looking for the answer for this I figured it out after a bit more sleep. I had to get rid of the return and the second function. So the code now looks like this add_action( ‘woocommerce_single_product_summary’, ‘my_units_sold_counts’, 19 ); function my_units_sold_counts($units_sold) { global $product; $units_sold = get_post_meta( $product->id, ‘total_sales’, … Read more

WordPress reading old version of functions.php, breaks site

The issue was indeed server side caching. Bluehost was very helpful in providing a way to fix it via FTP. Do the following: In the /wp-content/mu-plugins directory, there is a file called endurance-browser-cache.php. By renaming the file, for example to endurance-browser-cache.old, visiting the site, and returning the name to endurance-browser-cache.php, WordPress will have had to … Read more

Graphic before title – Specific Category

Try the following code: function new_title( $title ) { if(in_the_loop() && !is_singular(‘page’)) { $picArray = array( ‘3’ => ‘&#x26a0;’, ‘5’ => ‘&#x26c5;’, ); $cats = get_the_category(); $cat = $cats[0]->term_id; $title = $picArray[$cat] . ‘ ‘ . $title; } return $title; } add_filter( ‘the_title’, ‘new_title’ ); First, we check if we are in the loop, and … Read more