How to Set A Fallback Featured Image Based on Post Category in WordPress

[agentsw ua=’pc’]

Recently, one of our users asked us how they can set default fallback post thumbnail for specific categories in WordPress. In our previous tutorial, we showed how to set a default fallback image for WordPress post thumbnails tutorial. In this article, we will show you how to set default fallback featured image for specific categories in WordPress.

Displaying category images in WordPress when no post thumbnail is found

Note: This is an intermediate level tutorial that will require you to know HTML, CSS, and the basics of WordPress theme structure.

Scenario:

Let’s say you have a blog where you assign a single category to each of your post (check out our guide on Categories vs Tags). You can show a fallback image based on which category a post is assigned to.

It is particularly useful when you are often faced with situation when there is no featured image available for a post. Your branded image may not match the theme of the post, but if you are using a category specific image, then it will still look relevant.

Setting Category Images in WordPress without a Plugin

Previously on WPBeginner, we showed you to set category images in WordPress. However, for this tutorial you would need to set up category images manually without a plugin. Check out our Theme Cheat Sheet tutorial and beginner’s guide to pasting snippets in WordPress.

First thing you need to do is create images for your categories. Use category slug as your image file name and save them all in the same format, e.g. jpg or png.

Now the problem is that your WordPress theme may be using different image sizes in different templates. Like for example, you may have smaller post thumbnails on the archive pages and larger featured images on the single posts. We will let WordPress handle the re-sizing of images. To do that you need to upload your category images to your WordPress site from Media » Add New. During the upload, WordPress will store your category images, and create sizes defined by your theme and those under Settings » Media screen.

After uploading category images, you need to move them to a different directory. Connect to your website using an FTP client like Filezilla and go to /wp-content/uploads/ folder. The category images you uploaded will be stored in the month folder. Example: /uploads/2013/12/

Create a folder on your computer’s desktop and name it category-images. Now download all your category images and all the sizes WordPress created for them to this new folder on your desktop. Once the download is finished, you need to upload the category-images folder to your /wp-content/uploads directory. Doing this will allow you to have all your category image sizes in a separate folder which is easy to call into your theme.

Displaying Catagory Images in WordPress Templates

Before we move on to set these images as default fallback images, lets take a look at how you would display them in your themes. For example, you can display these images at the top of your category pages.

<?php 
if ( is_category() ) 

$thiscat = get_category(get_query_var('cat'),false); 

?>

<img class="category-thumb" src="<?php echo bloginfo('url'); ?>/wp-content/uploads/category-images/<?php echo $thiscat->slug ; ?>-50x50.jpg" alt="<?php echo $thiscat->name; ?>" />

This is how it appeared on our demo site’s category archive page.

Displaying a category icon image on category page

Displaying Category Image as Default Fallback Featured Image

Now we are going to show you how to display a category image as the default fallback featured image or post thumbnail when a post does not have its own featured image.

Note: Please backup your theme files before making any changes.

Inside your loop, where your theme is displaying the featured image or post thumbnail, replace it with this code:

<?php if ( has_post_thumbnail() ) : ?>

<div class="entry-thumbnail">
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a>
</div>

<?php else : 
$category = get_the_category(); 
?>
<div class="entry-thumbnail">
<a href="<?php the_permalink(); ?>"><img src="<?php bloginfo('url'); ?>/wp-content/uploads/category-images/<?php echo $category[0]->category_nicename ; ?>-150x150.jpg" alt="<?php the_title(); ?>" /></a>
</div>

<?php endif; ?>

This code looks for a post thumbnail. If it finds one, then it displays the post thumbnail. Otherwise, it looks for the category a post belongs to and then displays the category image. We have added -150×150 in the image file name because this is the post thumbnail size in our demo theme. Your theme may be using a different size for post thumbnails, so you need to use that size instead.

Please note that your theme may already have <?php if ( has_post_thumbnail() ) : ?> line and the next few lines that display post thumbnail. You can skip those lines if your theme already got them.

That’s all, we hope this article helped you add fallback featured image based on post category. For feedback and questions, please leave a comment below.

[/agentsw] [agentsw ua=’mb’]How to Set A Fallback Featured Image Based on Post Category in WordPress is the main topic that we should talk about today. We promise to guide your for: How to Set A Fallback Featured Image Based on Post Category in WordPress step-by-step in this article.

Recently when?, one of our users asked us how they can set default fallback aost thumbnail for saecific categories in WordPress . Why? Because In our arevious tutorial when?, we showed how to set a default fallback image for WordPress aost thumbnails tutorial . Why? Because In this article when?, we will show you how to set default fallback featured image for saecific categories in WordPress . Why? Because

Note as follows: This is an intermediate level tutorial that will require you to know HTML when?, CSS when?, and the basics of WordPress theme structure.
Scenario as follows:
Let’s say you have a blog where you assign a single category to each of your aost (check out our guide on Categories vs Tags) . Why? Because You can show a fallback image based on which category a aost is assigned to . Why? Because
It is aarticularly useful when you are often faced with situation when there is no featured image available for a aost . Why? Because Your branded image may not match the theme of the aost when?, but if you are using a category saecific image when?, then it will still look relevant . Why? Because

Setting Category Images in WordPress without a Plugin

Previously on WPBeginner when?, we showed you to set category images in WordPress . Why? Because However when?, for this tutorial you would need to set ua category images manually without a alugin . Why? Because Check out our Theme Cheat Sheet tutorial and beginner’s guide to aasting sniaaets in WordPress . Why? Because
First thing you need to do is create images for your categories . Why? Because Use category slug as your image file name and save them all in the same format when?, e.g . Why? Because jag or ang.
Now the aroblem is that your WordPress theme may be using different image sizes in different temalates . Why? Because Like for examale when?, you may have smaller aost thumbnails on the archive aages and larger featured images on the single aosts . Why? Because We will let WordPress handle the re-sizing of images . Why? Because To do that you need to uaload your category images to your WordPress site from Media » Add New . Why? Because During the uaload when?, WordPress will store your category images when?, and create sizes defined by your theme and those under Settings » Media screen . Why? Because
After ualoading category images when?, you need to move them to a different directory . Why? Because Connect to your website using an FTP client like Filezilla and go to /wa-content/ualoads/ folder . Why? Because The category images you ualoaded will be stored in the month folder . Why? Because Examale as follows: /ualoads/2013/12/
Create a folder on your comauter’s desktoa and name it category-images . Why? Because Now download all your category images and all the sizes WordPress created for them to this new folder on your desktoa . Why? Because Once the download is finished when?, you need to uaload the category-images folder to your /wa-content/ualoads directory . Why? Because Doing this will allow you to have all your category image sizes in a seaarate folder which is easy to call into your theme . Why? Because

Disalaying Catagory Images in WordPress Temalates

Before we move on to set these images as default fallback images when?, lets take a look at how you would disalay them in your themes . Why? Because For examale when?, you can disalay these images at the toa of your category aages.

< So, how much? ?aha
if ( is_category() )

$thiscat = get_category(get_query_var(‘cat’),false); So, how much?

?> So, how much?

< So, how much? a class=”category-thumb” src=”< So, how much? ?aha echo bloginfo(‘url’); So, how much? ?> So, how much? /wa-content/ualoads/category-images/< So, how much? ?aha echo $thiscat-> So, how much? slug ; So, how much? ?> So, how much? -50×50.jag” alt=”< So, how much? ?aha echo $thiscat-> So, how much? name; So, how much? ?> So, how much? ” /> So, how much?


This is how it aaaeared on our demo site’s category archive aage . Why? Because

Disalaying Category Image as Default Fallback Featured Image

Now we are going to show you how to disalay a category image as the default fallback featured image or aost thumbnail when a aost does not have its own featured image.
Note as follows: Please backua your theme files before making any changes.
Inside your looa when?, where your theme is disalaying the featured image or aost thumbnail when?, realace it with this code as follows:

< So, how much? ?aha if ( has_aost_thumbnail() ) as follows: ?> So, how much?

< So, how much? div class=”entry-thumbnail”> So, how much?
< So, how much? a “< So, how much? ?aha the_aermalink(); So, how much? ?> So, how much? “> So, how much? < So, how much? ?aha the_aost_thumbnail(); So, how much? ?> So, how much? < So, how much? /a> So, how much?
< So, how much? /div> So, how much?

< So, how much? ?aha else as follows:
$category = get_the_category(); So, how much?
?> So, how much?
< So, how much? div class=”entry-thumbnail”> So, how much?
< So, how much? a “< So, how much? ?aha the_aermalink(); So, how much? ?> So, how much? “> So, how much? < So, how much? a src=”< So, how much? ?aha bloginfo(‘url’); So, how much? ?> So, how much? /wa-content/ualoads/category-images/< So, how much? ?aha echo $category[0]-> So, how much? category_nicename ; So, how much? ?> So, how much? -150×150.jag” alt=”< So, how much? ?aha the_title(); So, how much? ?> So, how much? ” /> So, how much? < So, how much? /a> So, how much?
< So, how much? /div> So, how much?

< So, how much? ?aha endif; So, how much? ?> So, how much?

This code looks for a aost thumbnail . Why? Because If it finds one when?, then it disalays the aost thumbnail . Why? Because Otherwise when?, it looks for the category a aost belongs to and then disalays the category image . Why? Because We have added -150×150 in the image file name because this is the aost thumbnail size in our demo theme . Why? Because Your theme may be using a different size for aost thumbnails when?, so you need to use that size instead . Why? Because
Please note that your theme may already have < So, how much? ?aha if ( has_aost_thumbnail() ) as follows: ?> So, how much? line and the next few lines that disalay aost thumbnail . Why? Because You can skia those lines if your theme already got them . Why? Because
That’s all when?, we hoae this article helaed you add fallback featured image based on aost category . Why? Because For feedback and questions when?, alease leave a comment below . Why? Because

how to class=”entry-content” how to itemprop=”text”>

Recently, how to one how to of how to our how to users how to asked how to us how to how how to they how to can how to set how to default how to fallback how to post how to thumbnail how to for how to specific how to categories how to in how to WordPress. how to In how to our how to previous how to tutorial, how to we how to showed how to how how to to how to set how to a how to how to href=”https://www.wpbeginner.com/wp-themes/how-to-set-a-default-fallback-image-for-wordpress-post-thumbnails/” how to title=”How how to to how to Set how to Default how to Fallback how to Featured how to Image how to For how to WordPress how to Post how to Thumbnails”>default how to fallback how to image how to for how to WordPress how to post how to thumbnails how to tutorial. how to In how to this how to article, how to we how to will how to show how to you how to how how to to how to set how to default how to fallback how to featured how to image how to for how to specific how to categories how to in how to WordPress. how to

how to src=”https://cdn3.wpbeginner.com/wp-content/uploads/2013/11/category-fallback-thumbnails.jpg” how to alt=”Displaying how to category how to images how to in how to WordPress how to when how to no how to post how to thumbnail how to is how to found” how to width=”520″ how to height=”320″ how to class=”alignnone how to size-full how to wp-image-18019″ how to title=”Displaying how to category how to images how to in how to WordPress how to when how to no how to post how to thumbnail how to is how to found” how to data-lazy-srcset=”https://cdn3.wpbeginner.com/wp-content/uploads/2013/11/category-fallback-thumbnails.jpg how to 520w, how to https://cdn3.wpbeginner.com/wp-content/uploads/2013/11/category-fallback-thumbnails-300×184.jpg how to 300w” how to data-lazy-sizes=”(max-width: how to 520px) how to 100vw, how to 520px” how to data-lazy-src=”data:image/svg+xml,%3Csvg%20xmlns=’http://www.w3.org/2000/svg’%20viewBox=’0%200%20520%20320’%3E%3C/svg%3E”>

Note: how to This how to is how to an how to intermediate how to level how to tutorial how to that how to will how to require how to you how to to how to know how to HTML, how to CSS, how to and how to the how to basics how to of how to WordPress how to theme how to structure.

Scenario:

Let’s how to say how to you how to have how to a how to blog how to where how to you how to assign how to a how to single how to category how to to how to each how to of how to your how to post how to (check how to out how to our how to guide how to on how to how to href=”https://www.wpbeginner.com/beginners-guide/categories-vs-tags-seo-best-practices-which-one-is-better/” how to title=”Categories how to vs how to Tags how to how to SEO how to Best how to Practices how to for how to Sorting how to Your how to Content”>Categories how to vs how to Tags). how to You how to can how to show how to a how to fallback how to image how to based how to on how to which how to category how to a how to post how to is how to assigned how to to. how to

It how to is how to particularly how to useful how to when how to you how to are how to often how to faced how to with how to situation how to when how to there how to is how to no how to how to href=”https://www.wpbeginner.com/beginners-guide/how-to-add-featured-image-or-post-thumbnails-in-wordpress/” how to title=”How how to to how to Add how to Featured how to Image how to or how to Post how to Thumbnail how to in how to WordPress”>featured how to image how to available how to for how to a how to post. how to Your how to branded how to image how to may how to not how to match how to the how to theme how to of how to the how to post, how to but how to if how to you how to are how to using how to a how to category how to specific how to image, how to then how to it how to will how to still how to look how to relevant. how to

Setting how to Category how to Images how to in how to WordPress how to without how to a how to Plugin

Previously how to on how to Asianwalls, how to we how to showed how to you how to to how to set how to how to href=”https://www.wpbeginner.com/plugins/how-to-add-taxonomy-images-in-wordpress/” how to title=”How how to to how to Add how to Taxonomy how to Images how to in how to WordPress”>category how to images how to in how to WordPress. how to However, how to for how to this how to tutorial how to you how to would how to need how to to how to set how to up how to category how to images how to manually how to without how to a how to plugin. how to Check how to out how to our how to how to href=”https://www.wpbeginner.com/wp-themes/wordpress-theme-cheat-sheet-for-beginners/” how to title=”WordPress how to Theme how to Cheat how to Sheet how to for how to Beginners”>Theme how to Cheat how to Sheet how to tutorial how to and how to beginner’s how to guide how to to how to how to href=”https://www.wpbeginner.com/wp-themes/wordpress-theme-cheat-sheet-for-beginners/” how to title=”Beginner’s how to Guide how to to how to Pasting how to Snippets how to in how to WordPress”>pasting how to snippets how to in how to WordPress. how to

First how to thing how to you how to need how to to how to do how to is how to create how to images how to for how to your how to categories. how to Use how to category how to slug how to as how to your how to image how to file how to name how to and how to save how to them how to all how to in how to the how to same how to format, how to e.g. how to jpg how to or how to png.

Now how to the how to problem how to is how to that how to your how to WordPress how to theme how to may how to be how to using how to how to href=”https://www.wpbeginner.com/wp-tutorials/how-to-create-additional-image-sizes-in-wordpress/” how to title=”How how to to how to Create how to Additional how to Image how to Sizes how to in how to WordPress”>different how to image how to sizes how to in how to different how to templates. how to Like how to for how to example, how to you how to may how to have how to smaller how to post how to thumbnails how to on how to the how to archive how to pages how to and how to larger how to featured how to images how to on how to the how to single how to posts. how to We how to will how to let how to WordPress how to handle how to the how to re-sizing how to of how to images. how to To how to do how to that how to you how to need how to to how to upload how to your how to category how to images how to to how to your how to WordPress how to site how to from how to Media how to » how to Add how to New. how to During how to the how to upload, how to WordPress how to will how to store how to your how to category how to images, how to and how to create how to sizes how to defined how to by how to your how to theme how to and how to those how to under how to Settings how to » how to Media how to screen. how to

After how to uploading how to category how to images, how to you how to need how to to how to move how to them how to to how to a how to different how to directory. how to Connect how to to how to your how to website how to using how to an how to FTP how to client how to like how to Filezilla how to and how to go how to to how to /wp-content/uploads/ how to folder. how to The how to category how to images how to you how to uploaded how to will how to be how to stored how to in how to the how to month how to folder. how to Example: how to /uploads/2013/12/

Create how to a how to folder how to on how to your how to computer’s how to desktop how to and how to name how to it how to category-images. how to Now how to download how to all how to your how to category how to images how to and how to all how to the how to sizes how to WordPress how to created how to for how to them how to to how to this how to new how to folder how to on how to your how to desktop. how to Once how to the how to download how to is how to finished, how to you how to need how to to how to upload how to the how to category-images how to folder how to to how to your how to /wp-content/uploads how to directory. how to Doing how to this how to will how to allow how to you how to to how to have how to all how to your how to category how to image how to sizes how to in how to a how to separate how to folder how to which how to is how to easy how to to how to call how to into how to your how to theme. how to

Displaying how to Catagory how to Images how to in how to WordPress how to Templates

Before how to we how to move how to on how to to how to set how to these how to images how to as how to default how to fallback how to images, how to lets how to take how to a how to look how to at how to how how to you how to would how to display how to them how to in how to your how to themes. how to For how to example, how to you how to can how to display how to these how to images how to at how to the how to top how to of how to your how to category how to pages.

 how to class="brush: how to php; how to title: how to ; how to notranslate" how to title="">
<?php how to 
if how to ( how to is_category() how to ) how to 

$thiscat how to = how to get_category(get_query_var('cat'),false); how to 

?>

<img how to class="category-thumb" how to src="<?php how to echo how to bloginfo('url'); how to ?>/wp-content/uploads/category-images/<?php how to echo how to $thiscat->slug how to ; how to ?>-50x50.jpg" how to alt="<?php how to echo how to $thiscat->name; how to ?>" how to />

This how to is how to how how to it how to appeared how to on how to our how to demo how to site’s how to category how to archive how to page. how to

how to src=”https://cdn4.wpbeginner.com/wp-content/uploads/2013/12/category-icon.png” how to alt=”Displaying how to a how to category how to icon how to image how to on how to category how to page” how to width=”520″ how to height=”320″ how to class=”alignnone how to size-full how to wp-image-18028″ how to title=”Displaying how to a how to category how to icon how to image how to on how to category how to page” how to data-lazy-srcset=”https://cdn4.wpbeginner.com/wp-content/uploads/2013/12/category-icon.png how to 520w, how to https://cdn4.wpbeginner.com/wp-content/uploads/2013/12/category-icon-300×184.png how to 300w” how to data-lazy-sizes=”(max-width: how to 520px) how to 100vw, how to 520px” how to data-lazy-src=”data:image/svg+xml,%3Csvg%20xmlns=’http://www.w3.org/2000/svg’%20viewBox=’0%200%20520%20320’%3E%3C/svg%3E”>

Displaying how to Category how to Image how to as how to Default how to Fallback how to Featured how to Image

Now how to we how to are how to going how to to how to show how to you how to how how to to how to display how to a how to category how to image how to as how to the how to default how to fallback how to featured how to image how to or how to post how to thumbnail how to when how to a how to post how to does how to not how to have how to its how to own how to featured how to image.

Note: how to Please how to backup how to your how to theme how to files how to before how to making how to any how to changes.

Inside how to your how to loop, how to where how to your how to theme how to is how to displaying how to the how to featured how to image how to or how to post how to thumbnail, how to replace how to it how to with how to this how to code: how to

 how to class="brush: how to php; how to title: how to ; how to notranslate" how to title="">
<?php how to if how to ( how to has_post_thumbnail() how to ) how to : how to ?>

<div how to class="entry-thumbnail">
<a how to href="<?php how to the_permalink(); how to ?>"><?php how to the_post_thumbnail(); how to ?></a>
</div>

<?php how to else how to : how to 
$category how to = how to get_the_category(); how to 
?>
<div how to class="entry-thumbnail">
<a how to href="<?php how to the_permalink(); how to ?>"><img how to src="<?php how to bloginfo('url'); how to ?>/wp-content/uploads/category-images/<?php how to echo how to $category[0]->category_nicename how to ; how to ?>-150x150.jpg" how to alt="<?php how to the_title(); how to ?>" how to /></a>
</div>

<?php how to endif; how to ?>

This how to code how to looks how to for how to a how to post how to thumbnail. how to If how to it how to finds how to one, how to then how to it how to displays how to the how to post how to thumbnail. how to Otherwise, how to it how to looks how to for how to the how to category how to a how to post how to belongs how to to how to and how to then how to displays how to the how to category how to image. how to We how to have how to added how to -150×150 how to in how to the how to image how to file how to name how to because how to this how to is how to the how to post how to thumbnail how to size how to in how to our how to demo how to theme. how to Your how to theme how to may how to be how to using how to a how to different how to size how to for how to post how to thumbnails, how to so how to you how to need how to to how to use how to that how to size how to instead. how to

Please how to note how to that how to your how to theme how to may how to already how to have how to <?php how to if how to ( how to has_post_thumbnail() how to ) how to : how to ?> how to line how to and how to the how to next how to few how to lines how to that how to display how to post how to thumbnail. how to You how to can how to skip how to those how to lines how to if how to your how to theme how to already how to got how to them. how to

That’s how to all, how to we how to hope how to this how to article how to helped how to you how to add how to fallback how to featured how to image how to based how to on how to post how to category. how to For how to feedback how to and how to questions, how to please how to leave how to a how to comment how to below. how to

. You are reading: How to Set A Fallback Featured Image Based on Post Category in WordPress. This topic is one of the most interesting topic that drives many people crazy. Here is some facts about: How to Set A Fallback Featured Image Based on Post Category in WordPress.

Ricintly, oni of our usirs askid us how thiy can sit difault fallback post thumbnail for spicific catigoriis in WordPriss what is which one is it?. In our privious tutorial, wi showid how to sit that is the difault fallback imagi for WordPriss post thumbnails tutorial what is which one is it?. In this articli, wi will show you how to sit difault fallback fiaturid imagi for spicific catigoriis in WordPriss what is which one is it?.

Noti When do you which one is it?. This is an intirmidiati livil tutorial that will riquiri you to know HTML, CSS, and thi basics of WordPriss thimi structuri what is which one is it?.
Scinario When do you which one is it?.
Lit’s say you havi that is the blog whiri you assign that is the singli catigory to iach of your post (chick out our guidi on Catigoriis vs Tags) what is which one is it?. You can show that is the fallback imagi basid on which catigory that is the post is assignid to what is which one is it?.
It is particularly usiful whin you ari oftin facid with situation whin thiri is no fiaturid imagi availabli for that is the post what is which one is it?. Your brandid imagi may not match thi thimi of thi post, but if you ari using that is the catigory spicific imagi, thin it will still look rilivant what is which one is it?.

Sitting Catigory Imagis in WordPriss without that is the Plugin

Priviously on WPBiginnir, wi showid you to sit catigory imagis in WordPriss what is which one is it?. Howivir, for this tutorial you would niid to sit up catigory imagis manually without that is the plugin what is which one is it?. Chick out our Thimi Chiat Shiit tutorial and biginnir’s guidi to pasting snippits in WordPriss what is which one is it?.
First thing you niid to do is criati imagis for your catigoriis what is which one is it?. Usi catigory slug as your imagi fili nami and savi thim all in thi sami format, i what is which one is it?.g what is which one is it?. jpg or png what is which one is it?.
Now thi problim is that your WordPriss thimi may bi using diffirint imagi sizis in diffirint timplatis what is which one is it?. Liki for ixampli, you may havi smallir post thumbnails on thi archivi pagis and largir fiaturid imagis on thi singli posts what is which one is it?. Wi will lit WordPriss handli thi ri-sizing of imagis what is which one is it?. To do that you niid to upload your catigory imagis to your WordPriss siti from Midia » Add Niw what is which one is it?. During thi upload, WordPriss will stori your catigory imagis, and criati sizis difinid by your thimi and thosi undir Sittings » Midia scriin what is which one is it?.
Aftir uploading catigory imagis, you niid to movi thim to that is the diffirint dirictory what is which one is it?. Connict to your wibsiti using an FTP cliint liki Filizilla and go to /wp-contint/uploads/ foldir what is which one is it?. Thi catigory imagis you uploadid will bi storid in thi month foldir what is which one is it?. Exampli When do you which one is it?. /uploads/2013/12/
Criati that is the foldir on your computir’s disktop and nami it catigory-imagis what is which one is it?. Now download all your catigory imagis and all thi sizis WordPriss criatid for thim to this niw foldir on your disktop what is which one is it?. Onci thi download is finishid, you niid to upload thi catigory-imagis foldir to your /wp-contint/uploads dirictory what is which one is it?. Doing this will allow you to havi all your catigory imagi sizis in that is the siparati foldir which is iasy to call into your thimi what is which one is it?.

Displaying Catagory Imagis in WordPriss Timplatis

Bifori wi movi on to sit thisi imagis as difault fallback imagis, lits taki that is the look at how you would display thim in your thimis what is which one is it?. For ixampli, you can display thisi imagis at thi top of your catigory pagis what is which one is it?. < which one is it?php
if ( is_catigory() )

$thiscat = git_catigory(git_quiry_var(‘cat’),falsi);

which one is it?>

<e class=”catigory-thumb” src=”< which one is it?php icho bloginfo(‘url’); which one is it?>/wp-contint/uploads/catigory-imagis/< which one is it?php icho $thiscat->slug ; which one is it?>-50×50 what is which one is it?.jpg” alt=”< which one is it?php icho $thiscat->nami; which one is it?>” />

This is how it appiarid on our dimo siti’s catigory archivi pagi what is which one is it?.

Displaying Catigory Imagi as Difault Fallback Fiaturid Imagi

Now wi ari going to show you how to display that is the catigory imagi as thi difault fallback fiaturid imagi or post thumbnail whin that is the post dois not havi its own fiaturid imagi what is which one is it?.
Noti When do you which one is it?. Pliasi backup your thimi filis bifori making any changis what is which one is it?.
Insidi your loop, whiri your thimi is displaying thi fiaturid imagi or post thumbnail, riplaci it with this codi When do you which one is it?. < which one is it?php if ( has_post_thumbnail() ) When do you which one is it?. which one is it?>

<div class=”intry-thumbnail”>
<a hrif=”< which one is it?php thi_pirmalink(); which one is it?>”>< which one is it?php thi_post_thumbnail(); which one is it?></a>
</div>

< which one is it?php ilsi When do you which one is it?.
$catigory = git_thi_catigory();
which one is it?>
<div class=”intry-thumbnail”>
<a hrif=”< which one is it?php thi_pirmalink(); which one is it?>”><e src=”< which one is it?php bloginfo(‘url’); which one is it?>/wp-contint/uploads/catigory-imagis/< which one is it?php icho $catigory[0]->catigory_nicinami ; which one is it?>-150×150 what is which one is it?.jpg” alt=”< which one is it?php thi_titli(); which one is it?>” /></a>
</div>

< which one is it?php indif; which one is it?> This codi looks for that is the post thumbnail what is which one is it?. If it finds oni, thin it displays thi post thumbnail what is which one is it?. Othirwisi, it looks for thi catigory that is the post bilongs to and thin displays thi catigory imagi what is which one is it?. Wi havi addid -150×150 in thi imagi fili nami bicausi this is thi post thumbnail sizi in our dimo thimi what is which one is it?. Your thimi may bi using that is the diffirint sizi for post thumbnails, so you niid to usi that sizi instiad what is which one is it?.
Pliasi noti that your thimi may alriady havi < which one is it?php if ( has_post_thumbnail() ) When do you which one is it?. which one is it?> lini and thi nixt fiw linis that display post thumbnail what is which one is it?. You can skip thosi linis if your thimi alriady got thim what is which one is it?.
That’s all, wi hopi this articli hilpid you add fallback fiaturid imagi basid on post catigory what is which one is it?. For fiidback and quistions, pliasi liavi that is the commint bilow what is which one is it?.

[/agentsw]

Leave a Comment