1

In quite a few wordpress projects I have a request in which Projects (or other post type) have to be featured in the Portfolio page (or other listing page) instead of the default date sorting lists.

Usually i create a checkbox as a custom field, but then it is not easy to know what projects are marked in the admin edit page.

Creating a category would also be a solution, but I am not sure if it is a good practice to deliver a theme with predefined categories.

I also read about creating a archived post status, so that only 'published' entries would then be featured.

So, what do you think is the best way to achieve this?

4
  • Why do you not use checkbox as a custom field and check the condition on your portfolio template if it is set to featured then it should have some text on it or have different layout. Commented Jan 22, 2015 at 12:56
  • Yes, this is what i usually do, but it is not very handy. Maybe there is a better approach
    – Marc
    Commented Jan 22, 2015 at 12:59
  • This highly depends on what you want to do with featured posts. Basically custom fields or a taxonomy are the options. @rarst just wrote a nice blog post on this general issue which might help you choose: rarst.net/wordpress/term-vs-field
    – kraftner
    Commented Jan 22, 2015 at 13:56
  • @ Marc, better approach means? I think you are confused with yourself. Firstly tell us what is your real requirement? Commented Jan 22, 2015 at 14:08

2 Answers 2

2

OK, after reading Rarst post i went with the taxonomy term option. It was very simple:

  1. Just after the register_taxonomy call, i added one line of code wp_insert_term('Featured','filter'); being filter my taxonomy.
  2. Then I modified the query in the template, adding the line 'filter' => 'Featured', inside the args.

Now I only see the featured projects in the portfolio page, which was my main goal. Moreover, i can easily list the featured projects in the backend, as well as Quick-edit this option.

UPDATE:

As a side note, if you then wanted to list the categories without the Featured category:

  1. Exclude the term by id:

<?php $featured_term = get_term_by('name', 'Featured', 'filter'); $featured_id = $featured_term->term_id; $args = array('taxonomy' => 'filter', 'exclude'=>$featured_id); wp_list_categories($args); ?>

1
  • Great you solved your problem yourself! You can now also accept this as answer to your problem.
    – kraftner
    Commented Jan 23, 2015 at 11:50
0

This sounds like stickies, but alas they don't work for custom post types.

I would say if you are already using custom field for it, but not happy with interface then just fix the latter — interface.

You can access custom field in admin just as you can in front end. Use it to make featured status more prominent in a fitting way. For example you could make post list in admin adhere to the same sorting logic, bringing featured to the top and keeping order the same as front end displays it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.