How to display post label name instead of a featured image/thumbnail in blogger?

Viewed 100

First, let me tell you that I am not from a coding background. Recently, I started a website using blogger. I don't have any featured image/thumbnail to any of my posts. So, blogger is displaying the text 'no image'. I am able to change the text name from 'no image' to some other text. But what I need is to change the text 'no image' into the label name that I have given for that particular post. So that, every post's thumbnail displays that particular label for that post instead of "no image".

For example, if the label for a post titled 'title_1' is 'label_1', then the thumbnail for the post 'title_1' should display 'label_1' instead of 'no image'.

Please help me, how to change it into label name.

1 Answers

Assuming each posts has only 1 label, you can get the name of that post label by using <data:post.labels.first.name/>.

So, here's what you need to do :

  1. Locate the text that you want to change, in this case no image or whatever text you change it into.
  2. Find out what variable name is being used to display post data. You can do this by looking at some <data:.../> tag around the code that you want to change from the first step. This usually <data:post.../> but might be something else. Few examples are: <data:post.title/>, <data:post.publishedDate/>, and <data:post.body/>.
  3. If post is the variable name used for posts data, then you can use <data:post.labels.first.name/> to replace no image. Otherwise, change post to whatever variable name being used to display post data.

Note that Blogger post labels are sorted alphabetically. So this solution might not solve your problem if you have more than one label per post. In that case, you need to work with <b:loop>.

Related