Skip to main content
11 events
when toggle format what by license comment
Feb 2, 2017 at 21:13 comment added Anwer AR Glad to hear that. You're welcome
Feb 2, 2017 at 20:56 vote accept olliew
Feb 2, 2017 at 20:04 comment added Anwer AR Sorry! i was bit late in updating the modified code. please see the modified source code and use it accordingly. it should work correctly...
Feb 2, 2017 at 20:04 history edited Anwer AR CC BY-SA 3.0
modified source
Feb 2, 2017 at 19:25 comment added olliew Thanks Abdul. I have changed my code so that the values match. The class is being applied to absolutely all of my posts, even those where I haven't ticked the box for them to become featured
Feb 2, 2017 at 18:54 comment added Anwer AR i see. now this is the good approach. a minor note about meta field. you've added meta field named "meta-box-checkbox" and in my example function i have used a meta field named "featured_post". so these two values should match. i am modifying original source from your question
Feb 2, 2017 at 17:30 comment added olliew I've tried this approach and added the code to my original question. At the moment all my posts have a class of featured_post, possibly left over from my previous use of the category method, even though I've now deleted that category! This is my first attempt at using Wordpress hooks, meta-boxes, etc
Feb 2, 2017 at 14:28 comment added Anwer AR The category method has no problem at all if you are working on a specific project. but if you are planning to release your theme commercially or in wp theme directory then probably the category method is not a good idea. because you will have large number of users using your theme and wp category is designed used for categorizing posts. so respect the wp standards & let it work on its way and create another method to make featured posts. I've mentioned about meta fields in my answer and this is the appropriate method.
Feb 2, 2017 at 13:21 comment added olliew Hi Abdul. The category method from codee.io above does work. What makes you say using categories is a bad thing? Don't sticky post stick to the top? I want featured posts that are interspersed with the rest of the content.
Feb 2, 2017 at 11:14 history edited Anwer AR CC BY-SA 3.0
added more explanation
Feb 2, 2017 at 11:07 history answered Anwer AR CC BY-SA 3.0