I hope I have the right forum to post this… Something has changed in WordPress that won’t allow some of my custom PHP code to work. My child theme stopped working correctly as of a couple months back. I’ve isolated the code within functions.php that is causing the issue but I need help understanding why it suddenly doesn’t work anymore. If I comment out the section of the code that says “$strOutput = $strOutput . ‘<div style=”margin-top:3px; margin-bottom:3px;width:50%;”>’ . do_shortcode(‘”‘’) . ‘</div>’;” the site displays correctly, when uncommented, the entire lower section of my <body> is missing.
Here is the code.
function shortcode_insert_sermons () {
query_posts(array('post_type' => 'message','showposts' => 0, 'orderby' => 'post_date', 'order' => 'DESC'));
$strOutput="";
if (have_posts()) :
while ( have_posts() ) : the_post();
$strOutput="<article class="et_pb_post">";
$strOutput = $strOutput . "<h2 class="entry-title"><a href="" . get_permalink() . "">" . get_the_title() . "</a></h2>";
$strOutput = $strOutput . '<p>' . the_date('M j, Y','','',false) . '</p>';
$audio_info = get_post_meta(get_the_ID(), 'message_audio', TRUE);
if ($audio_info) {
$strOutput = $strOutput . '<div style="margin-top:3px; margin-bottom:3px;width:50%;">' . do_shortcode('' . $audio_infohttps://projectdmc.org/support/topic/php-code-causing-me-grief/ . '') . '</div>';
}
$strOutput = $strOutput . '<p>' . get_the_excerpt() . '</p>';
$strOutput = $strOutput . "<p><a href="" . get_permalink() . "">view sermon</a></p>";
$strOutput .= '</article>';
endwhile;
endif;
wp_reset_query();
return $strOutput;
}
add_shortcode('insert_sermons', 'shortcode_insert_sermons');