WordPress.org

Forums

[Plugin: List category posts] Need help reordering so that date comes first (3 posts)

  1. johnrhopkins
    Member
    Posted 5 years ago #

    I'm using the template parameter and I've created the following code. The issue is it doesn't wrap the list items in an unordered ( <ul class="lcp_catlist"> ) list like the default version does.

    THIS IS MY VERSION

    //Show category?
    if ($cat_link_string != ''){
    	$output = '<p><strong>' . $cat_link_string . '</strong></p>';
    }else{
    	$output = '';
    }
    //Posts loop:
    foreach($catposts as $single):
    	$output.= '<li>' . get_the_time($atts['dateformat'], $single);
    	$output .= ''.'<a href="' . get_permalink($single->ID) . '">' . $single->post_title . '</a>';
    
    	//Show author?
    	if($atts['author']=='yes'){
    		$lcp_userdata = get_userdata($single->post_author);
    		$output.=" - ".$lcp_userdata->user_nicename;
    	}
    	//Show content?
    	if($atts['content']=='yes' && $single->post_content){
    		$output .= "<p>$single->post_content</p>";
    	}
    	//Show excerpt?
    	if($atts['excerpt']=='yes' && $single->post_excerpt && !($atts['content']=='yes' && $single->post_content) ){
    		$output .= '<p>' . $single->post_excerpt . '</p>';
    	}
    	$output.='</li>';
    endforeach;
    ?>

    THIS IS THE DEFAULT VERSION

    //Show category?
    if ($cat_link_string != ''){
    	$output = '<p><strong>' . $cat_link_string . '</strong></p>';
    }else{
    	$output = '';
    }
    //Posts loop:
    foreach($catposts as $single):
    	$output .= '<li><a href="' . get_permalink($single->ID) . '">' . $single->post_title . '</a>';
    	//Style for date:
    	if($atts['date']=='yes'){
    		$output.= ' - ' . get_the_time($atts['dateformat'], $single);
    	}
    	//Show author?
    	if($atts['author']=='yes'){
    		$lcp_userdata = get_userdata($single->post_author);
    		$output.=" - ".$lcp_userdata->user_nicename;
    	}
    	//Show content?
    	if($atts['content']=='yes' && $single->post_content){
    		$output .= "<p>$single->post_content</p>";
    	}
    	//Show excerpt?
    	if($atts['excerpt']=='yes' && $single->post_excerpt && !($atts['content']=='yes' && $single->post_content) ){
    		$output .= '<p>' . $single->post_excerpt . '</p>';
    	}
    	$output.='</li>';
    endforeach;
    ?>

    http://wordpress.org/extend/plugins/list-category-posts/

  2. johnrhopkins
    Member
    Posted 5 years ago #

    OK, I just tried renaming the default page to default2 and using that one, unchanged. It also doesn't wrap the LIST with an UNORDERED LIST. Looking deeper...

  3. johnrhopkins
    Member
    Posted 5 years ago #

    OK, the provided template is just missing the unordered list wrapper.
    This works>>>>

    //Show category?
    if ($cat_link_string != ''){
    	$output = '<p><strong>' . $cat_link_string . '</strong></p>';
    }else{
    	$output = '';
    }
    $output .= '<ul class="lcp_catlist">';//For default ul
    //Posts loop:
    foreach($catposts as $single):
    	$output .= '<li>' . get_the_time($atts['dateformat'], $single);
    	$output.= '<br />'.'<a href="' . get_permalink($single->ID) . '">' . $single->post_title . '</a>';
    
    	//Show author?
    	if($atts['author']=='yes'){
    		$lcp_userdata = get_userdata($single->post_author);
    		$output.=" - ".$lcp_userdata->user_nicename;
    	}
    	//Show content?
    	if($atts['content']=='yes' && $single->post_content){
    		$output .= "<p>$single->post_content</p>";
    	}
    	//Show excerpt?
    	if($atts['excerpt']=='yes' && $single->post_excerpt && !($atts['content']=='yes' && $single->post_content) ){
    		$output .= '<p>' . $single->post_excerpt . '</p>';
    	}
    	$output.='</li>';
    endforeach;
    $output .= "</ul>";
    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic