shortcode executed in the page editor

From the add_shortcode() docs: Note that the function called by the shortcode should never produce an output of any kind. Shortcode functions should return the text that is to be used to replace the shortcode. Producing the output directly will lead to unexpected results. Your code should be: function vbshort_shortcode() { return ‘Hello shotcode!’; } … Read more

Images under 1MB are not being compressed

The closest answer you will find to the exact question you asked is: that feature does not exist, WordPress does not have an image compression feature. That’s not how compression works, compression isn’t something WP does. Your understanding of how WordPress handles image uploads, and your expectations, are incorrect. WP does not store images in … Read more

How to add template colors to custom block options in WordPress Gutenberg editor sidebar?

How can I add template colors (i.e., those black and pastel shades) to ColorPalette (“Input border color”)? In Gutenberg, you can get the block color palette in two ways: Use getSettings() in the block editor’s data (core/block-editor). E.g. import { select } from ‘@wordpress/data’; const colorPalette = select( ‘core/block-editor’ ).getSettings().colors; // PS: You can also … Read more

How to create templates for a custom module to show on the front end within my theme?

Templates in wordpress just needs to be valid PHP files. You need to place your template inside theme ( or child theme directory ). Have you placed the template in plugin directory ? if yes it won’t work. https://gist.github.com/gmazzap/1efe17a8cb573e19c086 Template file set via setTemplate must be in theme (or child theme) folder. For more details … Read more

How to call a function using a shortcode [closed]

Step 1 Define your shortcode callback function. You can find some examples for generating the output here. function your_shortcode_callback( $atts ) { // if attributes as used with shortcode, then do something with $atts // get data $enrolled_course = tutor_utils()->get_enrolled_courses_by_user(); // do something to turn the data into html string $output_html=””; // callback should return … Read more

Different custom templates for product category [closed]

try to use get_template_part(‘yourfile’) instead. the get_template_part() goes from theme root path. so if you have your template in woocommerce folder use: if( has_term( ‘course’, ‘product_cat’ ) ) { get_template_part(‘woocommerce/single-product-course’ ); } else { wc_get_template_part( ‘content’, ‘single-product’ ); } however probably should be better to make a folder that its not woocommerce, once woocoomerce folder … Read more

How to create WordPress custom end point with multiple parameters?

When you register a route, parameters accepted via the query string (eg. ?a=b&c=d) are not registered as part of the endpoint, like you have done. Those parameters just need to be defined in the args property: add_action( ‘rest_api_init’, function() { register_rest_route( ‘woo/v2’, ‘woocommerce/order_summary_by_date’, array( ‘methods’ => ‘GET’, ‘callback’ => ‘woocommerce_orders_by_dates’ ‘args’ => array( ‘start_date’ => … Read more