Automatically add to Category
-
Hey Guys.
Not sure if this should be in hacks or not, but my goal here is to do a kind of “catch all”, where if a post meets certain criteria, it would be put in a specific category automatically. For example, if the post has a Youtube Video, it would automatically be put into the (pre-existing) category, “Videos”.
<?php $youTubeVideo = get_post_meta($post->ID, 'Youtube Video', true); if (file($youTubeVideo) && !in_category('33387')) { // It has the Youtube meta but it's not in Videos.. so put it in Videos. } ?>
The topic ‘Automatically add to Category’ is closed to new replies.