So I am working on a site for a client of mine. We have about 50+ posts filed in a category called "Articles". I created a custom page template that has a custom query to display all the posts in a bullet list on this page, and if you click on it you can go directly to the post to read more or open a PDF directly. Where I am hitting a road block is we have 2 specific articles that are more then just PDF's, they are about 3-6 paragraphs instead. SO I wanted to know if it is possible to display all the posts in the list like I am now, and if it exceeds around 100 characters then revert to the excerpt we made for those posts specifically.
Currently my code looks like this:
<?php
//for each child of category 16 (articles), show title of posts
$cat_args=array('child_of' => 16, 'orderby' => 'name', 'order' => 'DESC');
$categories=get_categories($cat_args);
foreach($categories as $category) {
$args=array('showposts' => -1, 'category__in' => array($category->term_id), 'caller_get_posts'=>1);
$posts=get_posts($args);
if ($posts) {
echo '<h3><a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a></h3> ';
foreach($posts as $post) {
setup_postdata($post); ?>
<!--<li><?php the_title_attribute(); ?></li>-->
<ul>
<li><?php echo get_the_content(); ?></li>
</ul>
<?php
} // foreach($posts
} // if ($posts
} // foreach($categories
?>
Thank you! Been pulling my hair out for days on this one.