Multiple Shortcode Creation In Functions.php Using Else,ELSEIF


Please excuse my ignorance! I almost don’t know what I’m talking about.

Our website currently has php written to create shortcodes that pulls data (forum posts) based on when it was posted for a newsletter. Currently it is Weekly (7Day) or Daily (1Day). I am trying to add a new shortcode Thrice Weekly (2Day). I created the sql view to pull 2day (tested and working correctly) and added in the php where I thought it was necessary but it doesn’t seem to be working. I’m thinking the issue is in the IF, ELSE IF (having two ELSE IFs?)

Would appreciate any help!

/* Custom Shortcode - Morning Byte Email */
    add_filter('mailpoet_newsletter_shortcode', 'mailpoet_morning_byte', 10, 5);
    function mailpoet_morning_byte($shortcode, $newsletter, $subscriber, $queue, $newsletter_body) {
        $html_output .= '';
        if ($shortcode == '[forum:morning_byte_weekly]' || $shortcode == '[forum:morning_byte_daily]' || $shortcodee == '[forum:morning_byte_thriceweekly]'){
            global $wpdb;
            if ($shortcode == '[forum:morning_byte_weekly]') {$sql_view = 'POST_TOPICS_7DAY';}
            elseif ($shortcode == '[forum:morning_byte_daily]') {$sql_view = 'POST_TOPICS_1DAY';}
            elseif ($shortcode == '[forum:morning_byte_thriceweekly]') {$sql_view = 'POST_TOPICS_2DAY';}
            $myrows = $wpdb->get_results('SELECT pt.FORUM_ID,pt.FORUM_TITLE,pt.POST_TOPIC_ID FROM '. $sql_view .' pt LEFT JOIN _FORUM_SORT fs ON pt.FORUM_ID = fs.FORUM_ID ORDER BY fs.SORT');

Tracy Kistler 9 months 2022-05-24T08:02:43-05:00 0 Answers 0 views 0

Leave an answer