Custom shortcode is causing a WSOD

extract( shortcode_atts( ‘post_type’ => ‘publications_test’, ‘post_status’ => ‘publish’ ‘id’ => ”, ); The above is wrong. You have an array inside that function but it’s not in an actual array. Try this instead: extract( shortcode_atts(array( ‘post_type’ => ‘publications_test’, ‘post_status’ => ‘publish’, ‘id’ => ”, ), $atts, ‘testshortcode’); shortcode atts

Shortcode is not returned correctly

You should not echo any content in your shortcode. the_weekday() function echos the date. You can use output buffering or directly get the date: Output buffering: function custom_shortcode() { ob_start(); the_weekday(); $week = ob_get_contents(); ob_end_clean(); return ‘<img src=”https://wordpress.stackexchange.com/wp-content/themes/coworker/images/daily-social-image-” . $week . ‘.gif” width=”100%” />’; } add_shortcode( ‘weekday’, ‘custom_shortcode’ ); Or use the global $wp_locale to … Read more

Shortcode syntax errors

You’re missing semicolons after </li>, </ul>, and $output. You also shouldn’t be echoing inside string concatenation and not adding the <li> tag to $output. The below is your code with these fixes. function allphotos_shortcode(){ $images = get_field(‘fl_gallery’); if( $images ) { $output .= ‘<ul>’; foreach( $images as $image ) : $output .= ‘<li><a href=”‘ . … Read more

Function result goes outside div

You’re using a mix of echoing and returning. Here you’re starting by echoing: echo ‘<div class=”clear”></div>’; Here you’re putting the output into a variable (correctly): $output=”<div class=”row”>”; And here you’re just writing the content in quotes without echoing or assigning to a variable: ‘<div class=”col-md-8 grid-entry-wrapper”> <!– grid-entry-wrapper open –> <!– BLOG LOOP –> </div><!– … Read more

Div-Wrap with Functions.php in Childtheme using Shortcode!

Shortcodes come in two flavors: [shortcodename param1 = value, …, param-n = value] and [shortcodename param-1 = value, …, param-n = value]some content[/shortcodename] In both cases, add_shortcode(‘shortcodename’, ‘functionname’) function is identical. The functionname() function’s parameters, determine which flavor will be used: functionname($atts) is for shortcode with no closing tag, and functionname($atts, $content) is for shortcode … Read more

Shortcode is not working

It looks like you are trying to apply a shortcode to the title field. That is not supported by itself (only shortcodes in the post content are evaluated automatically), but easily remedied by adding it as a filter to get_the_tile in your plugin: add_filter (‘the_title’, ‘do_shortcode’); (I’m assuming that you ruled out other possible problems … Read more