get shortcode value

add_shortcode(‘the_chart ‘, ‘high_chart’); function high_chart($atts, $content = null) { //extract the cart and footer_caption value extract(shortcode_atts(array( ‘chart’ => null, ‘footer_caption’ => null), $atts)); /* * process your chart and footer_caption value as * $chart and $footer_caption and return the process data */ $return_html=”chart id:”. $chart.'<br/> Footer Caption:’. $footer_caption; return $return_html } For reference: https://codex.wordpress.org/Function_Reference/add_shortcode Hope … Read more

Pass a php string to a javascript variable

You can use the wp_localize_script to pass a variable to your javascript. Here is an example: wp_register_script(‘your_script_name’, ‘path/to/script.js’); $variables = array ( ‘footer_caption’ => $attr[‘footer_caption’], ); wp_localize_script(‘your_script_name’, ‘js_object_name’, $variables ); wp_enqueue_script(‘your_script_name’); Then you can acces to this variable by: js_object_name.footer_caption

doing an ajax request always outputs 0

Your custom functions should always go in your theme’s functions.php file (if they are not within plugin territory). You should never try to modify any core files outside the wp-content folder (except wp-config.php) as they will be overridden by future updates. Now, there are 2 ways to do what you want. 1 – Admin-ajax This … Read more

Locating Global Variables

Child themes The WordPress Way of modifying the theme’s page-templates/front-page.php is to create a child theme, then duplicate this file in the child theme and make the modifications there. Your modified template file will be loaded instead of the parent theme’s file. This allows the parent theme to be updated without losing the modifications made … Read more

Loading header.php on specific page

Okay. I got it working. I just had to create a copy of the header.php in my child theme, rename it and add if(is_page(XXXX)) { get_header(‘header-name’); } else { get_header(); } after the initial <?php in the page.php of my child theme.

Woocommerce – Filter Variable Products by Variation Attributes and Variations Regular Price

So, I finally figured out the answer… This may help someone in future. Here is the query that will first filter variable products for attribute Quantity which has term id 75 and then it will further filter result for variations which has price 500 set. $query = array( ‘post_status’ => ‘publish’, ‘post_type’ => array(‘product’, ‘product_variation’), … Read more