On the fourth post template, I’m getting a very strange placement of the title when there’s no featured image. (I have modified my loop-single-4 and single_template_4, but I already switched back to the parent theme versions to test this, and it still happens.)
Here’s what it looks like with a featured image:
http://www.screencast.com/t/ywzjdsUvO0C
Seems good to me. But here’s what happens without one. (The text is selected, it doesn’t have a background):
http://www.screencast.com/t/M3pKXn9Bul
Hmm…
On a similar note, let’s say I want to use has_post_thumbnail to sort out the template, so that it works like normal if there is one but looks more like style 2 if not. Would that solve my problem?
Hi,
Yes, I have also tested this and you are right. The thing is that these post styles haven’t been created to be used without a feature image, if you decide not to use a feature image you just set the post to use style 5 or default without setting a feature image.
I think the best to solve this to use another post template. If you want to change the code you could go into single_template_4.php file and add an else like this: http://screencast.com/t/HY6yYP6f9 and then set a height for the div you added, like this: http://screencast.com/t/iuS1ooBuhlx
Here is the code if you want to use it:
} else {
?> <div class="custom_class_without_image"></div>
<?php
Hope this helps!
Thanks
Thanks for the idea! I didn’t want to do it on a post-by-post basis (so. many. posts.) However, I couldn’t get it to style the way I wanted, either.
So this is what I did in the end:
1. Copied td_add_single_template_class to my functions.php, removed the filter for the parent function and added a filter for my child function
2. Updated the part of the function that puts in the default class, to first check for the case where the class is ‘single_template_4’ and !has_post_thumbnail(), and if so change the class to ‘single_template_2’ before adding it
3. Updated single_template_4.php, putting this conditional in:
if (in_array('single_template_4', get_body_class()))
4. Wrapped the entire remaining code in there, then added an else and copied the equivalent content from single_template_2.php and pasted it in the same way
It works! Needless to say, I’ve learned a lot about WordPress over the last two hours :p
