inov8ed 0 Report post Posted March 11, 2011 Hi, I would like to implement an if statement where there is a default feature image for a particular category. This page really nails down what I want to do: http://wordpress.stackexchange.com/questions/5013/can-i-set-a-default-featured-image-for-a-category How can I implement this as a hook with PlatformPro? Basically, anywhere the thumbnail is called, if there is no thumbnail assigned, then it could draw it from a default for that category. I am using Auto Post Thumbnail, which automatically assigns a thumbnail if there isn't one based on the first image on the post, but this doesn't really work when I am using the same image over and over (ie, a default image for that category). It is creating multiple thumbnails rather than just calling a default. Thanks! -Adam Share this post Link to post Share on other sites
kastelic 6 Report post Posted March 12, 2011 First, have you looked here? http://www.pagelines.com/docs/base-child-theme Share this post Link to post Share on other sites
inov8ed 0 Report post Posted March 12, 2011 Hi, I know where to and how to actually add a hook, but I am unsure how to take the concept I am talking about and turn it into a hook (since they are talking about editing the templates). Do you have any suggestions? Thanks. -ADam Share this post Link to post Share on other sites
catrina 103 Report post Posted March 12, 2011 If the Auto Post Thumbnail isn't working out and doesn't exactly fit in with what you're trying to accomplish here, perhaps it can be deactivated and uninstalled and then we can figure out how to implement the hook from there. Please read the docs before posting. Please do not private message me unless I ask you to. Designer | Catrina Dulay Founder | Catrina and Mouse Share this post Link to post Share on other sites
inov8ed 0 Report post Posted March 13, 2011 If we completely forget Auto Post Thumbnail for a minute, how can I implement this code so that it replaces anywhere at php call to thumbnail is done" ` <?php if ( (function_exists('has_post_thumbnail')) && (has_post_thumbnail()) ) { the_post_thumbnail('thumbnail'); } else { ?> <?php } endif; } ?> ` The idea would be to have this if statement replace any featured image with a specific image if it is in a specific category... Thanks! -Adam Share this post Link to post Share on other sites
inov8ed 0 Report post Posted March 13, 2011 I guess i could edit the template file directly, right? Is there a way to copy over the file to base and make this change or do I have to create a hook to do this? Thanks. -Adam Share this post Link to post Share on other sites
kastelic 6 Report post Posted March 14, 2011 Yes, you can copy any template file, for example template.postloop.php over to your base directory and edit at will. Share this post Link to post Share on other sites
inov8ed 0 Report post Posted March 14, 2011 Is this new in 1.3? When I tried to do this with the 404 page, it was not possible except editing it directly in the main theme... -Adam Share this post Link to post Share on other sites
cmunns 16 Report post Posted March 14, 2011 That's because there is no 404 file in the original core files it's just part of the template.postloop.php file which you can use to customize it. You'll see the conditionals on the bottom for is_search and is_404 etc Share this post Link to post Share on other sites
inov8ed 0 Report post Posted April 18, 2011 Hey Adam, Just getting back to this as I upgrade files. I want to not have to edit the main theme 404 file to get the feature. In my version 1.3.5 there is no is_404 conditional in the template.postloop.php file only an is_search conditional. Do I have to add in the is_404 condition to override the main theme 404 section? Thanks. -Adam Share this post Link to post Share on other sites
cmunns 16 Report post Posted April 18, 2011 The 404 page in recent versions is the section.noposts.php file. Share this post Link to post Share on other sites
inov8ed 0 Report post Posted August 3, 2011 I am just coming back to this for something else and was wondering about a function to just insert a featured image if no featured image is declared and use a specific image for a specific category. I am using Base with an edited functions.php file. Would this function look right: add_action('pagelines_before_maincontent', 'add_missing_thumbnail'); function add_missing_thumbnail() { ?><?php if ( (function_exists('has_post_thumbnail')) && (has_post_thumbnail())) : ?> <?php the_post_thumbnail('thumbnail'); ?> <?php else :?> <?php endif;?><?[/code] Is this the right place to put the function and the right hook? How do I deal with posts that have multiple categories? Do I have to mess with the template files or add a filter as well? Ideally, I would love to be able to add another "if" before the category check to check for the first image and make it a thumbnail so I don't have to use the "auto post thumbnail" plugin as it doesn't always seem to work right... -Adam Share this post Link to post Share on other sites
kastelic 6 Report post Posted August 3, 2011 It looks like you have all the correct syntax, but a few problems. pagelines_before_maincontent is, i believe, outside the post loop so in that case, i don't think template tags like the_post_thumbnail() will work. Try pagelines_inside_top_theloop instead. the_post_thumbnail() refers to a featured image which is tied to a specific post, not a category or archive. So i think this would only work on single post pages. Share this post Link to post Share on other sites
inov8ed 0 Report post Posted August 4, 2011 Thanks. I wasn't intending the feature image be attached to a category, only a post (I just wanted to have it put a default image automatically if there was nothing already declared). Is there a better thing to use than the_post_thumbnail? How can I account for a post in multiple categories? Instead of having it look for a file called category.jpg, should I hard code each category (and just make sure there would be no posts that conflict)? Can I add another loop in there to use the first image as thumbnail if there is no thumbnail declared? I could probably then remove the Auto Post Thumbnail plugin. Thanks. -Adam Share this post Link to post Share on other sites
inov8ed 0 Report post Posted August 5, 2011 Anyone have any suggestions? Thanks. -Adam Share this post Link to post Share on other sites