Pre-populating new Page creation with shortcodes

You can add any default content you like, but I don’t know of a way of doing it just for Pages (the following will apply to both Pages and Posts): add_filter( ‘default_content’, ‘my_default_post_content’ ); function my_default_post_content( $content ) { $content = “Hello World!”; return $content; } (place this in your functions.php file)

Shortcodes: override a shortcode / change shortcode on the fly

Here’s what I’ve done:created a shortcode where I do [myplugin language=”fr” id=”5″][myplugin language=”us” id=”8″] and then, when this page is called, it calls myplugin twice. If it’s not on the right page, my plugin returns nothing. So, when this page is called: if it’s on a domain like “mydomain.fr” I just call do_shortcode(“othershortcode 5”) if … Read more

Woocommerce Filter Main Loop by Tag [closed]

First Question: Solved by copying and modifying the “archive-product.php” template file. if(is_product_tag(array(‘audio’))) : include ‘archive-product-audio.php’; // includes custom loop else: // default archive loop endif; Second Question: Solved by simply filtering the Recent Products shortcode via “function.php”. add_filter(‘woocommerce_shortcode_products_query’, ‘removeAudioTags’); function removeAudioTags($args){ $args[‘tax_query’] = array(array( ‘taxonomy’ => ‘product_tag’, ‘field’ => ‘slug’, ‘terms’ => array(‘audio’), ‘operator’ => … Read more

How to echo an array returned by a function

You cannot return an array from inside a shortcode, this will lead to the following error Array to string convertion ….. The output from a shortcode needs to be a string, so you need to convert your array to a string. You also cannot echo anything inside a shortcode, neither can you use functions or … Read more