Forum

Thread tagged as: Question, Problem, Blog

Categories problem

The idea is to have the latest blog post with a 'next-meeting' category appear in the top spot in the sidebar.

Whenever I write a new post and assign it to the 'next-meeting' category, it doesnt replace the previous one in that spot. What am I doing wrong?

<?php  
         perch_blog_custom(array(
           'sort-order' =>'DESC', 
           'count'  => 1,
           'template' => 'sidebar-post-in-list.html',
           'category' => 'next-meeting',
         ));
?>
<div class="sidebar-img-wrap">
    <!-- Featured post image -->
    <perch:if exists="image"><img src="<perch:blog id="image" type="image" width="300" height="400" crop="true" />" alt="<perch:blog id="postTitle" />" /></perch:if>

    <!-- Title of feature block (e.g. 'Next Meeting') -->
    <p><span><perch:blog id="feature-title" type="text" label="Feature title" editor="markitup" 
    html="true" size="m" /></span></p>
</div>

<!-- Blog post title -->
<h2 class="sidebar-featured-heading"><a href="<perch:blog id="postURL" type="hidden" />" rel="bookmark" class="p-name">
<perch:blog id="postTitle" type="text" label="Title" required="true" size="xl autowidth" order="1" /></a></h2> 

<!-- Description (Blog post excerpt) -->
<div class="sidebar-featured-description entry-summary">
    <perch:blog id="excerpt" type="textarea" html="false"/>
    <a class="button more" href="<perch:blog id="postURL" type="hidden" />">></a>
</div>

<div class="sidebar button register">
   <a href="../register.php"><span>Register</span></a>
</div>

..its basically a problem of how to get the latest one to appear without having to uncategorize the previous one

Chris James

Chris James 0 points

  • 5 years ago
<?php  
        perch_blog_custom(array(
          'sort-order' =>'DESC', 
          'count'  => 1,
          'template' => 'sidebar-post-in-list.html',
          'category' => 'next-meeting',
        ));
?>

You forgot to tell it what to sort...

perch_blog_custom(array(
                'count'      => 1,
                'template'   => 'sidebar-post-in-list.html',
                'sort'       => 'postDateTime',
                'sort-order' => 'DESC',
                'category' => 'next-meeting'
            ));
Drew McLellan

Drew McLellan 2638 points
Perch Support

That should do it.

Working great now. Thank you Robert and Drew - I appreciate the help