Instructional Technology, Photography, Web Development

Creating featured posts section in Expression Engine

This brief tutorial shows a quick way of creating a “featured posts” section for your Expression Engine website. This method involved using a drop-down list with options to include/exclude the post from the featured posts section.

Login

media-1235403830756.png

Login to your site and click on the Admin tab on the control panel.

Create a new field for your weblog

custom-fields-expressionengine.png

Click Weblog Administration > Custom Weblog Fields, then chose Add/Edit Custom Fields for the blog that you want to create a featured listing section for. Next, click Create a New Custom Field and create a name, label, and field type for your new field.

Set field preferences

custom-fields-expressionengine-1.png

For field type, make sure to choose Drop-down list. In the Select Options area, type your yes and no. These will be your options for choosing to include or exclude the post from your features section. Make sure to take note of your field name because you’ll need that in the next step. I’ve named mine homepage-display.

Create your template

Now that you’ve created your custom fields, it’s time to make a template to display your featured listings. In this tutorial we’re not going to do anything in the way of styling – I’ll just go over the code needed to make everything work.

We’ll use a regular EE weblog tag to list our posts, but add the search parameter to display only listings that we’ve specifically chosen to show.

{exp:weblog:entries weblog="blog-name-here" search:homepage-display ="=yes"}
{body}
{/exp:weblog:entries}

This example is extremely simple, but you could make it as complex as you need. For example, you may want to pull from multiple blogs, only from specific categories, or refine your search by any number of available parameters.


Tagged as: , , ,

2 Responses »

  1. Can you explain the last part of the weblog:entries tag, the part from “search:” till the end of that tag? I have never seen this before. Where in the documentation could I read more about this? Why is there an equal sign before the “yes”?

    • Hey Rory,

      Sorry for the delayed response. I’m busy working on redesigning this blog and converting it to EE 2.0 and haven’t been paying attention to the comments! The search bit is just searching for entries where the “display on homepage” field contains a “yes” value. You can actually do some pretty cool stuff with search. Let me know if you still have questions and I’ll make a quick tutorial on it!

Leave a Response


Please note: comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.