• rose.jim

    (@rosejimverizonnet)


    Previously suggested that a shortcode be provided to list all breaking news records. See https://www.ma4jr.org/broken-news/

    This just copies code from your plugin, but I’m sure there is a more portable way to implement this.

    [insert_php]
    	$html = '';
    	$jm_breaking_news_args = array(
    		'post_type' => 'jm_breaking_news',
    		'posts_per_page' => -1,
    	);
    	$current_time = strtotime(current_time('mysql'));
    	echo date('l dS \o\f F Y h:i:s A', $current_time);
    
    	$jm_breaking_news = new WP_Query($jm_breaking_news_args);
    	if ($jm_breaking_news->have_posts()) : while ($jm_breaking_news->have_posts()) : $jm_breaking_news->the_post();
    		$post_time = strtotime(get_the_date('r'));
    		echo date('l dS \o\f F Y h:i:s A', $post_time);
    
    		if (get_post_meta(get_the_ID(), 'jm_breaking_news_target', true) == 1) {
    			$target = 'target="_blank"';
    		} else {
    			$target = '';
    		}
    		if (get_post_meta(get_the_ID(), 'jm_breaking_news_in_ex', true) == 1) {
    			$link = get_post_meta(get_the_ID(), 'jm_breaking_news_internal_link', true);
    		} else {
    			$link = get_post_meta(get_the_ID(), 'jm_breaking_news_link', true);
    		}
    		if (get_post_meta(get_the_ID(), 'jm_breaking_news_color', true)) {
    			$style = 'style="background-color:' . get_post_meta(get_the_ID(), 'jm_breaking_news_color', true) . ';"';
    		} else {
    			$style = '';
    		}
    
    		$html = '<section class="breaking-news-box">';
    		$html .= '<div class="breaking-news-left" ' . $style . '>';
    		$html .= '<h2 class="breaking-news-left-h2">' . __('Breaking News', 'jm-breaking-news') . '</h2>';
    		$html .= '</div>';
    		$html .= '<div class="breaking-news-right">';
    		$html .= '<h2 class="breaking-news-right-h2"><a href="' . $link . '" ' . $target .'>' . get_the_title() . '</a></h2>';
    		$html .= '</div>';
    		$html .= '</section>';
    
    		echo $html;
    
    	endwhile; endif;
    	wp_reset_query();
    
    [/insert_php]

    https://www.ads-software.com/plugins/jm-breaking-news/

Viewing 1 replies (of 1 total)
  • Plugin Author Jacob Martella

    (@arenapigskin)

    Cool stuff here. I will definitely look into putting this into the next version of the plugin. Thanks for the idea!

Viewing 1 replies (of 1 total)
  • The topic ‘Shortcode for full list of past breaking news’ is closed to new replies.