is_page “range” for if statement?

I think you should create range as variable and set it to is_page() something like this should work. $range = range(310, 326); if(is_page($range)){ // your code.. } is_page() function can accept array as argument. And range() function return array. This example works fine for me.

Shortcode with no attribute but has value

When no attribute is used but a value is provided, the value is added to $atts[0]. Using $atts[0], I’m now able to get the value output doing the following: function audio_shortcode($atts) { if($atts[0] != ”) { return ‘ <div class=”audiofile”> <audio controls> <source src=”‘ . $atts[0] . ‘” type=”audio/mpeg”> </audio> </div>’; } } add_shortcode(‘audio’, ‘audio_shortcode’);

Instagram URL is converted into oEmbed

Figured it out. Embed shortcode stores the oemebd data as post meta using md5 hash. wp-includes/class-wp-embed.php // Check for a cached result (stored in the post meta) $key_suffix = md5( $url . serialize( $attr ) ); $cachekey = ‘_oembed_’ . $key_suffix; $cachekey_time=”_oembed_time_” . $key_suffix; And has a cache mechanism to fetch new data only after … Read more

Add custom variable in Contact Form 7 mail body

You should do it like so: add_action( ‘wpcf7_init’, ‘custom_add_form_tag_my_source’ ); function custom_add_form_tag_my_source() { // “my-source” is the type of the form-tag wpcf7_add_form_tag( ‘my-source’, ‘custom_my_source_form_tag_handler’ ); } function custom_my_source_form_tag_handler( $tag ) { return isset( $_COOKIE[‘my_source’] ) ? $_COOKIE[‘my_source’] : ”; } See the documentation for more details. Or you can also try this, to parse regular … Read more

How can I included CSS to a page or a shortcode? [closed]

Simply follow the link to the has_shortcode() documentation in the last answer to the duplicate question. There you’ll find: function custom_shortcode_scripts() { global $post; if ( is_a( $post, ‘WP_Post’ ) && has_shortcode( $post->post_content, ‘custom-shortcode’) ) { wp_enqueue_script( ‘custom-script’); } } add_action( ‘wp_enqueue_scripts’, ‘custom_shortcode_scripts’); For styles this would be: function custom_shortcode_styles() { global $post; if ( … Read more

How to set Contact Form 7 fields default value using shortcode attribute? [closed]

the destination-email attribute requires an additional filter to be hooked to work, as detailed in cf7 doc and this forum thread, you need to ensure you do the following 4 steps: 1) in addition to the short code attribute, [contact-form-7 id=”123″ title=”Contact Form” destination-email=”[email protected]”] 2) you need to, add_filter( ‘shortcode_atts_wpcf7’, ‘custom_shortcode_atts_wpcf7_filter’, 10, 3 ); function … Read more

custom shortcode will not display the wrapped content

Because the shortcode must return a string. Avoid using the “echo” function in shortcode. Instead of doing that: function my_shortcode_function($content){ echo ‘<div class=”wrap”>’; echo ‘<div class=”col”>’.$content.'</div>’; echo ‘</div>’; } Do that: function my_shortcode_function($content){ $shortcode_return = ‘<div class=”wrap”>’; $shortcode_return .= ‘<div class=”col”>’.$content.'</div>’; $shortcode_return .= ‘</div>’; return $shortcode_return; } Or use object buffering: function my_shortcode_function($content){ ob_start(); ?> … Read more