Forum

Thread tagged as: Question, Blog

Displaying Posts by Tag in Blog App

I'm trying to create an argument that would allow blog posts to be displayed by tag using the post_in_list.html template. I understand the perch_get function, but I'm trying to display specific tags on one stream, but grouped together by that tag. Being somewhat of a newb at writing php arguments, I can't seem to get there. Any help you could provide would be great.

Hope that makes sense.

Greg Stone

Greg Stone 0 points

  • 5 years ago
Rachel Andrew

Rachel Andrew 394 points
Perch Support

Can you show us your code so far?

I solved it. I just needed to pass the a custom variable through.

if (perch_get('tag')) {
                    perch_blog_custom(array(
                            'tag'        => $doosan,
                            'template'   => $template,
                            'count'      => $posts_per_page,
                            'sort'       => $sort_by,
                            'sort-order' => $sort_order,
                            ));

                    $posts_displayed = true;
                }

If I wanted to text against multiple tags to create an output, how would I do this? I can only seem to test against one or the other, but not both as true.


if (perch_get('tag') and (perch_get('tagtwo'))) { perch_blog_custom(array( 'tag' => $ex, 'new' => $new, 'template' => $template, 'count' => $posts_per_page, 'sort' => $sort_by, 'sort-order' => $sort_order, )); $posts_displayed = true; }
Drew McLellan

Drew McLellan 2638 points
Perch Support

if (perch_get('tag') && perch_get('tagtwo')) {
    ... both tags are set ...
}

I feel like I'm close. Do I need to pass an array to exclude any posts the specific tags I don't want to show up?


if (perch_get('tag')) { perch_blog_custom(array( 'tag' => array($ex, !$used), 'template' => $template, 'count' => $posts_per_page, 'sort' => $sort_by, 'sort-order' => $sort_order, )) ; $posts_displayed = true; }
Drew McLellan

Drew McLellan 2638 points
Perch Support

Do I need to pass an array to exclude any posts the specific tags I don't want to show up?

I don't understand what you mean. Particularly "exclude any posts the specific tags".