Community Forums › Forums › Archived Forums › General Discussion › Streamline Theme – Questions on "featured image"
Tagged: featured image, streamline
- This topic has 15 replies, 2 voices, and was last updated 11 years, 4 months ago by ludvig.
-
AuthorPosts
-
August 17, 2013 at 12:25 pm #57060ludvigMember
Hey,
I was wondering whether the "featured image", that originally comes with the theme and is placed above posts, can be customized to show on specific posts rather than on ALL posts or NO posts.
Currently I have disabled it due to it giving me trouble with my old posts; giving rise to duplicate pictures and adding to that that my old blog posts pictures are in terrible resolution and do not look good in the format of the featured image.
(There is an option to disable the duplicate pictures in the theme options, but I have crossed that box and it is still giving me issues on a few posts)Now I think the "featured image" of Streamline looks great, but only when done correctly. It looks awful on my old posts. What I would like to do is to disable it for all old posts, but add it to my new posts and select images that look nice in that format.
So, is this possible to do; can I adjust for the "featured image" function above the posts to be customized per post?
http://www.startgainingmomentum.comAugust 17, 2013 at 12:44 pm #57061Brad DaltonParticipantYes you can add conditional tags with an array of page/post i.d's after the function to the PHP code in your child themes functions.php file.
Or change the conditional in this code in your functions file.
Or you can use CSS code:
.home .post-image { display: none; }
View the source code to find the post/page i.d in the body class.
Nite these code snippets are samples and would need to be customized to your needs.
August 17, 2013 at 12:46 pm #57063ludvigMemberWow, thanks a lot for the quick answer Brad!
I'll post again if I get a problem.
August 20, 2013 at 12:24 pm #57613ludvigMemberHey again,
I've been trying to get it working, but I'm having some trouble. I've only been toying with CSS & PHP files for two weeks and barely understand how to structure it.
Question:
1.Do I need to collect every PageID and insert manually into the code? (Because none of my old posts fit the format for the featured above picture and would therefore not look well with it)
2. Once having collected these PageIDs (not the hard part), WHERE and HOW do I put them into the PHP, could you post an example? When I say how, what I'm really asking is how to separate the IDs and how to "finish" the code.
Would it be like this?/** Add post image above post title */
add_action( 'genesis_before_post', 'streamline_post_image' );
function streamline_post_image() {if ( pageID1, pageID2, PageID3, etc...() ) return;
if ( $image = genesis_get_image( 'format=url&size=post-image' ) ) {
printf( '', get_permalink(), $image, the_title_attribute( 'echo=0' ) );
}}
August 20, 2013 at 12:49 pm #57623Brad DaltonParticipantYou add an array:
Or you can tag them and add the conditional tag
if ( has_tag( 'brads-tag' ) ) return;
August 20, 2013 at 1:34 pm #57644ludvigMemberThe issue has now been resolved, though it took some time to manually look up and write all the IDs.
I want to note for future readers that in my case it had to be is single not is page, because all of my old blog posts that look horrible with the Streamline featured image function were single posts.
Thanks a lot Brad,
I will likely post a few more questions in the coming days and weeks seeing as how I have so much to learn and so much to do until I am content with the appearance of my blog. I hope they too will be answered as quickly and skillfully!🙂
August 20, 2013 at 2:03 pm #57659ludvigMemberActually I was wrong, the issue is not entirely resolved.
I only fixed it INSIDE the posts by doing that. So now I got 50 % of the problem solved.
http://www.startgainingmomentum.com/
If you take a look at my blog you'll note that on the home/front page it looks bad with the featured pictures. But inside the posts it looks as it should.I already got the correct array and combinations of IDs, I just need to understand which code to use so that I can remove the same combination of featured images from my front page.
I've tried a bunch of different variations, including is_home and is_front_page but I am coming up short for the moment.
Any thoughts of what I can do?
August 20, 2013 at 3:05 pm #57720Brad DaltonParticipantAugust 21, 2013 at 9:07 am #57922ludvigMemberI've been trying to use the CSS code (and checked out your post on it on your blog) and yeah it works, but it effectively eliminates ALL the featured images in the posts shown on my home page/ blog template.
And I do not want to completely eliminate it, I only want it to be hidden from the "ugly", old images, that I have in my previous blog posts. I want to keep the featured pictures showing in the home page/blog template for all the new posts I make.
Thus far I have been able to eliminate the featured images inside the posts by using the ".single (array( post id)" command that you showed me.
But those ugly featured images are still showing on the home page/blog template.
Is there no way to customize it on the home page/blog template in the exact same manner that I've been able to do with the posts?
Perhaps I am misunderstanding this, I am very new to PHP/CSS.
August 21, 2013 at 3:49 pm #58033Brad DaltonParticipantYou can use the remove action in a custom function:
You will need to change the conditional tag.
August 22, 2013 at 1:17 pm #58253ludvigMemberThanks for being persistent in helping me Brad, but I am a hardcase at this stuff 🙂
I am having trouble understanding how I am supposed to change the conditional tags appropriately.. I managed to do it the last time but this is proving a bit difficult.
Here is how the code looks for my previous PHP that was successful in removing the featured image from inside the posts:
/** Add post image above post title */
add_action( 'genesis_before_post', 'streamline_post_image' );
function streamline_post_image() {if ( is_single( array( 140, 145, 154, 91, 160, 161, 162, 173, 180, 206, 194, 213, 239, 291, 312, 323, 333, 382, 424, 493, 516, 562, 622, 659, 684, 717, 752, 791, 750, 816, 847, 862, 884, 889, 950, 969, 1030, 1015, 1057, 1086, 1105, 1159, 1185, 1228, 1246, 1257, 1263, 1295 ) ) ) return;
if ( is_page ( 28 ) ) return;if ( $image = genesis_get_image( 'format=url&size=post-image' ) ) {
printf( '', get_permalink(), $image, the_title_attribute( 'echo=0' ) );
}}
How would I go about adjusting the new code you suggested?
Here is how I have written it right now just under the section above , but it is obviously completely wrong as it crashes my page:add_action('genesis_post_content', 'remove_featured_image_single');
function remove_featured_image_single() {
if(is_single( 140, 145, 154, 91, 160, 161, 162, 173, 180, 206, 194, 213, 239, 291, 312, 323, 333, 382, 424, 493, 516, 562, 622, 659, 684, 717, 752, 791, 750, 816, 847, 862, 884, 889, 950, 969, 1030, 1015, 1057, 1086, 1105, 1159, 1185, 1228, 1246, 1257, 1263, 1295 ) ) {
remove_action( 'genesis_post_content', 'genesis_do_post_image' );}
}
I basically just replaced where you had category to what had worked in the code above for me seeing as how there are many posts that need to be adjusted and the issue is non-category specific,. But it didn't work. I am messing up the code because I don't really understand how to write it properly yet.
August 22, 2013 at 1:43 pm #58256ludvigMemberIt no longer crashes my page when I changed it to:
add_action('genesis_post_content', 'remove_featured_image_specific_category');
function remove_featured_image_specific_category() {
if( is_single( array( 140, 145, 154, 91, 160, 161, 162, 173, 180, 206, 194, 213, 239, 291, 312, 323, 333, 382, 424, 493, 516, 562, 622, 659, 684, 717, 752, 791, 750, 816, 847, 862, 884, 889, 950, 969, 1030, 1015, 1057, 1086, 1105, 1159, 1185, 1228, 1246, 1257, 1263, 1295 ) ) ) {
remove_action( 'genesis_post_content', 'genesis_do_post_image' );}
}
But it produces no effect
August 22, 2013 at 3:34 pm #58281Brad DaltonParticipantI don't think this hook will work on the home page, only on posts.
genesis_post_content
August 23, 2013 at 1:23 pm #58475ludvigMemberHm.. Ok.
Damn, I can't believe no one else has had to before to solve this problem. I've been searching a lot for how other people have solved this, but I can't find anyone.
All posts I find are only about hiding posts using categories.
I'll keep searching and update if I find something.
In the meantime I will inactivate the feature picture command.
August 23, 2013 at 2:21 pm #58510Brad DaltonParticipantMost people use CSS however i believe its simply a matter of changing the hook. I will work this out when i have time.
August 24, 2013 at 12:35 pm #58607ludvigMemberI see.
Cool. I really appreciate you taking time to help me.
-
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.