Community Forums › Forums › Archived Forums › General Discussion › Conditional Tags Question
- This topic has 18 replies, 2 voices, and was last updated 10 years, 6 months ago by PainterMommy.
-
AuthorPosts
-
September 19, 2013 at 2:02 pm #63427PainterMommyMember
I am working on a site http://singletosmitten.com/ and I am using the Genesis hooks plugin to add a large graphic at the top of each page. We are using different graphics for each page. I am having trouble getting the blog graphic to show on the blog page.
This is the code I am using but it isn't working for me. I also tried the "single" conditional tag and that is not working either. #14 is the number of the blog page. Here is the link to the blog page - http://singletosmitten.com/blog/
<?php
if(is_page( 14 ) ) { ?>
<center>
</center>
<?php }
?>Any ideas on how I can get the image to display correctly? I appreciate it.
DAWN
September 19, 2013 at 2:24 pm #63435Brad DaltonParticipantI think you would be far better off creating a custom field for this if you plan on adding unique images before each page and/or page.
This will add a new box to every edit screen where you can simply choose an existing image from your media library or upload a new image which is only display before the content on that post or page. http://wpsites.net/web-design/add-unique-header-images-using-custom-fields/
You would need to change th hook in the code on that post from genesis_header to genesis_before_loop or genesis_before_content_sidebar_wrap.
Or you can use this PHP code in your child themes functions.php file for one image
https://gist.github.com/braddalton/6629292
September 19, 2013 at 3:03 pm #63447PainterMommyMemberBecause I already have the images on all the other pages, I went ahead and added the code you provided to the functions.php (for the blog page) and I am still not seeing the image on the blog page. Sigh... Any ideas?
September 19, 2013 at 3:24 pm #63448Brad DaltonParticipantDid you add the HTML for your image to the code between the div tags?
September 19, 2013 at 3:46 pm #63452PainterMommyMemberYes, here is the code I added:
/** Add image before blog page */
function image_before_blog() {
if(is_page(blog) )
echo '<div class="custom-image">http://singletosmitten.com/wp-content/uploads/2013/09/Marabeth-Banner-Blog_small.jpg</div>';
};
add_action('genesis_before_loop', 'image_before_blog');September 20, 2013 at 4:47 am #63499Brad DaltonParticipantThat won't work as its simply a link to the image.
You will need to insert the image into your editor and grab the HTML for the image which needs to be pasted between the div tags in my PHP code.
September 20, 2013 at 11:05 am #63542PainterMommyMemberYes, that is what I did.
September 20, 2013 at 1:07 pm #63560Brad DaltonParticipantIt looks like you only pasted the url and not the HTML. It it working?
September 20, 2013 at 1:27 pm #63567PainterMommyMemberOK, I updated the code to include the html, but it still isn't working. Here is the code:
/** Add image before blog page */ function image_before_blog() { if(is_page(blog) ) echo '<div class="custom-image"><img src="http://singletosmitten.com/wp-content/uploads/2013/09/Marabeth-Banner-Blog_small.jpg"/></div>'; }; add_action('genesis_before_loop', 'image_before_blog');
This is the page that I need the image to show up on: http://singletosmitten.com/blog/
September 20, 2013 at 2:04 pm #63575Brad DaltonParticipantIf you have selected to use a static front page in your reading settings, then you can use the is_home() conditional tag for your blog page.
Please change this line in your code from this:
if(is_page(blog) )
To:
if(is_home() )
September 20, 2013 at 4:24 pm #63587PainterMommyMemberThe blog is not set as the homepage though. Does that make a difference?
September 20, 2013 at 4:35 pm #63590Brad DaltonParticipantThe is_home() conditional works for displaying content on your blog page when you have selected a static page as your front page and your blog page as your posts page in your Reading Settings. http://wpsites.net/web-design/using-conditional-tags-for-home-front-blog-pages/#Blog_Page_Template
September 21, 2013 at 7:10 am #63645PainterMommyMemberOh geez. Sorry about that. OK, I did that and things are a bit off. Can you check it out for me? http://singletosmitten.com/blog/
September 21, 2013 at 7:40 am #63646Brad DaltonParticipantLooks like you have a problem with the hook position which you can change and the styling which you can change using the div class
.custom-image
September 21, 2013 at 8:08 am #63651PainterMommyMemberI added the code in the functions.php. I am not sure what I need to adjust in order to get the page to look like it is supposed to. I wish I was better with code. I am still a novice so I appreciate any help / direction that you might have.
September 21, 2013 at 8:19 am #63653Brad DaltonParticipantChange this line:
add_action('genesis_before_loop', 'image_before_blog');
To this:
add_action('genesis_after_header', 'image_before_blog');
Or this:
add_action('genesis_before_content_sidebar_wrap', 'image_before_blog');
September 21, 2013 at 8:38 am #63656PainterMommyMemberOK, that seemed to have worked somewhat, but the spacing / padding is off in comparison to the other pages. Here is an example of how it is supposed to look - http://singletosmitten.com/work-with-me/
October 4, 2013 at 9:44 am #65359PainterMommyMemberI did not hear back from ya so I wanted to check in. Any ideas on how I can get the blog page to look like the other pages? Right now the image is being pushed down a little too much. I appreciate any help that you might have for me. 🙂
October 7, 2013 at 6:34 am #65644PainterMommyMemberAnyone?
-
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.