[Plugin: Category Post Shortcode] how to hide old event from categor post listing
-
Hi there,
I am using this plugin to display list of news and events on my webpage.
Could anyone please tell me how to hide them from the list if they events are already passed or archived?Many thanks!
http://wordpress.org/extend/plugins/category-post-shortcode/
Viewing 1 replies (of 1 total)
-
Following is my code
What I am trying to do is if it is event page, display the events that are not past.
Anyone please help?<?php /* Plugin Name: category post shortcode Plugin URI: http://ibnuyahya.com/wordpress-plugins/category-post-shortcode/ Description: To display post by category in your page/post Author: ibnuyahya Author URI: http://ibnuyahya.com/ Version: 1.0 */ /* * * How to use * ============================================================================= * just put this shortcode in your post or pages * * [cat totalposts="3" category="1,3" thumbnail="true" excerpt="true" ] * * totalposts - your total number of post to display. default is -1 * category - category id. use comma , for multiple id * thumbnail - set true if you want to display thumbnail. default is false * excerpt - set true if you want to display excertp. default is true * orderby - your post will order by . default post_date . check http://codex.wordpress.org/Template_Tags/get_posts for detail * * thumbnail * ============================================================================= * create custom field key as thumbnail-url and put your thumbnail url in the value area * * style at your own * ============================================================================= * you need to style your category-post-shortcode plugin in your style.css example .cat-post{ width:100%; } .cat-post-list{ display: block; margin-bottom: 20px; position: relative; } .cat-post-images{ float:left; width:140px; display:block; } .cat-content{ width:350px; float:right; } .cat-post-title{ display: block; width:100%; } .cat-clear{ clear:both; } */ function cat_func($atts) { extract(shortcode_atts(array( 'class_name' => 'cat-post', 'totalposts' => '-1', 'category' => '', 'thumbnail' => 'false', 'excerpt' => 'true', 'orderby' => 'post_date', 'order' => '' ), $atts)); $output = '<div class="'.$class_name.'">'; global $post; $myposts = get_posts("numberposts=$totalposts&category=$category&orderby=$orderby&order=$order"); foreach($myposts as $post) { setup_postdata($post); $output .= '<div class="cat-post-list">'; if($thumbnail == 'true' && get_post_meta($post->ID, 'thumbnail-url',true) != "") { $output .= '<div class="cat-post-images"><a href="'.get_permalink().'"><img src="'.get_post_meta($post->ID, 'thumbnail-url',true).'" /></a></div>'; } //if category is news elseif(get_post_meta($post->ID, 'thumbnail-url',true) == "" && $category != 10){ $output .= ' <a href="'.get_permalink().'"><div class="date"> <div class="date-month">'.get_the_time('M').'</div> <div class="date-day">'.get_the_time('j').'</div> </div></a>'; } //if category is event elseif(get_post_meta($post->ID, 'thumbnail-url',true) == "" && $category == 10){ $output .= ' <a href="'.get_permalink().'"><div class="date"> <div class="date-month">'.the_event_start_date(null,FALSE,'M'). '</div> <div class="date-day">'.the_event_start_date(null,FALSE,'j').'</div> </div></a>'; } $todaysDate = date('m/d/Y'); $eventDate = the_event_start_date('j F Y'); // If Category is Event (Added by Jung Son 28th March 2011) if ($category == 10) { $output .= '<div class="cat-content"><span class="cat-post-title"><a href="'.get_permalink().'">'.get_the_title().'</a></span><br> <span class="cat-post-date">' .the_event_start_date('j F Y').'</span><br>'; if ($excerpt == 'true') { $output .= '<span class="cat-post-excerpt"> '.get_the_excerpt().'</span> <a href="'.get_permalink().'">read more »</a>'; } } // If Category is NOT EVENT (Added by Jung Son 28th March 2011) else { $output .= '<div class="cat-content"><span class="cat-post-title"><a href="'.get_permalink().'">'.get_the_title().'</a></span><br> <span class="cat-post-date">' .get_the_time('j F Y').'</span><br>'; if ($excerpt == 'true') { $output .= '<span class="cat-post-excerpt">'.get_the_excerpt().'</span> <a href="'.get_permalink().'">read more »</a>'; } } $output .= '</div> <div class="cat-clear"></div> </div>'; }; $output .= '</div>'; return $output; } add_shortcode('cat', 'cat_func'); ?>
Viewing 1 replies (of 1 total)
The topic ‘[Plugin: Category Post Shortcode] how to hide old event from categor post listing’ is closed to new replies.