Community Forums › Forums › Archived Forums › General Discussion › hire php expert for function
Tagged: wordpress function
- This topic has 18 replies, 2 voices, and was last updated 8 years, 6 months ago by handsun.
-
AuthorPosts
-
October 23, 2015 at 9:03 am #168837handsunParticipant
Hello! I had to switch over form my usual Genesis theme work to a woo commerce theme (Mystile) for a shopping cart job. My client needs the header to be different on different pages, so I was able to find this (an online tutorial) to add to the header.php of the site, which uses featured images as headers. I created a child theme of Mystile and started experimenting on the development site.
I would like to exclude featured images from displaying on the dynamic product pages, and I do not know the exact php to exclude product pages from this rule (so they have no header image), can you refer me to someone who could give me the line of code I would need to do that
Of course I will pay for your time
what I added to header.php in order to change each page's featured image to a unique banner (http://3dbizcenter.com/mm/)
if ( is_singular() && has_post_thumbnail( $post->ID ) && ( /* $src, $width, $height */ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'post-thumbnail') ) && $image[1] >= HEADER_IMAGE_WIDTH ) : // We have a new header image! echo get_the_post_thumbnail( $post->ID, 'post-thumbnail' ); else : ?>
I found this as a function but it is not working for me (product pages where We require no featured image) http://3dbizcenter.com/mm/product/splat/
add_filter('woocommerce_single_product_image_thumbnail_html', 'remove_featured_image', 10, 3); function remove_featured_image($html, $attachment_id, $post_id) { $featured_image = get_post_thumbnail_id($post_id); if ($attachment_id != $featured_image) { return $html; } return ''; }
http://3dbizcenter.com/mm/product/splat/October 23, 2015 at 12:53 pm #168848PorterParticipantSo your final goal is to exclude the featured images from the actual product pages? Show me an actual page, and describe the image you're trying to remove, and I should be able to work something out.
October 23, 2015 at 1:12 pm #168849handsunParticipantHI Porter, the site is above the first link, that shows the custom header images on the actual "pages" that have been created.
the second link shows a dynamic "product" page with the featured image above in the spot that the banner images are in the static pages, on these pages we can just remove the featured image no banner needed. they are all dynamically created by woocommerce and in url is product/, as you see here product/splat. The other pages also have products: urls below
http://3dbizcenter.com/mm/product/rust-freeze/
http://3dbizcenter.com/mm/product/atomic-blast-8oz/
http://3dbizcenter.com/mm/product/atomic-blast-14oz/
October 23, 2015 at 1:20 pm #168850PorterParticipantSo you're looking to remove the images (on the product pages) below the "view cart" button / cost area, but above the navigation, correct?
If so, I can help with that, just trying to figure out exactly what we're changing here, as that'll make me writing code on my end without access a whole lot easier 🙂
October 23, 2015 at 1:22 pm #168851handsunParticipantexactly, but we need to keep the featured images on the static pages! Let me know whatever you might need! Carin
October 23, 2015 at 1:25 pm #168852PorterParticipantJust to confirm what you mean by "static pages", toss me a link to what you're referring to.
If you could copy the contents of your functions.php file to pastebin and then send me a link to that page (once you post it, the url you're on will let me see that), that would help out as well, just so I can see what's going on, and avoid any potential conflicts (doubt there will be any, just want to double check).
October 23, 2015 at 1:29 pm #168853handsunParticipanthttp://3dbizcenter.com/mm/splat-bug-remover/
http://3dbizcenter.com/mm/rust-freeze/
http://3dbizcenter.com/mm/atomic-blast/
they contain the products listed above, if you click on a product from one of those pages it opens the dynamic "product" page. These static pages are the "Brand" pages that needed unique headers for each page, hence the featured image solution stated above (it was the only way I could find to do this, the Mystile theme did not work with any of the custom header plugins that I could find)
October 23, 2015 at 1:31 pm #168854PorterParticipantGotcha, so anything with /product needs that image removed, where as the actual brand pages that list various products will retain the header. I'll get something to you shortly.
Just to confirm, if I give you some code to add to functions.php, you'll be able to do so, correct?
October 23, 2015 at 1:32 pm #168855handsunParticipantOctober 23, 2015 at 2:00 pm #168857PorterParticipantCan you please post a link to your functions.php file? Either copy it to pastebin as I linked above, or host it on dropbox, anything works, I just need to see what's in that file to determine how featured images are being used in your theme.
October 23, 2015 at 2:08 pm #168858handsunParticipanthttp://pastebin.com/W3Kz9iMm
I also created a child theme
functions file is empty right now
October 23, 2015 at 2:40 pm #168863PorterParticipantSo I looked into your site a bit more, and it's actually happening on the page template level, so I'm not sure I can get to it from functions.php. That being said, I think I found a rather simple / elegant solution. Add this to your style.css:
.header .attachment-post-thumbnail { display: none; }
It is your "featured image" being used (easy enough to disable for a custom post type), but BOTH copies of the image (the one above the header, and in the post itself) are the same exact image, so if you kill one, you kill both. The above targets the css for the image in the header only, and leaves the one in the post. I see nothing wrong with this solution, and it should do the job just fine.
That being said, if you want to fix the "issue" at the root of the cause, I'd need to have the code for the page template. I don't know if "products" is created specifically for the theme (probably), or if that's a custom post type you defined (dynamicly, could be named tacos for all we care), but that would determine how easy it is to change. If you have a "single-products.php" copy the contents of that for me, and I can easily "fix" the issue without the css. Like I said, the css works, but this would technically be a bit more clean, though to the end-user it doesn't matter at all.
Let me know if:
-The css works
-You have a single-products.php (and pastebin that code).
October 23, 2015 at 2:43 pm #168865handsunParticipantI think that will also remove the featured images I am using on the "static" pages?
October 23, 2015 at 2:46 pm #168867PorterParticipantYou're absolutely right, my bad. Try adding:
.single-products .header .attachment-post-thumbnail { display: none; }
October 23, 2015 at 2:49 pm #168869handsunParticipantwoocommerce actually provides templates for single product, but because this is in the header.php, thats why i thought we could try and remove the featured image with conditional logic in functions.php.
can we communicate by email and I can send you the zip of the single-products folder, or maybe I just need to find a better way to add a unique header to the 4 static pages and I can remove that "featured image" code from header.php. thanks so much for your help on this! I will need your email anyway to send you over a paypal!
October 23, 2015 at 2:50 pm #168870PorterParticipantThis reply has been marked as private.October 23, 2015 at 3:08 pm #168872handsunParticipantI added it and no good, then I tried :
.single-product .header .attachment-post-thumbnail {
display: none;
}
still no good
October 23, 2015 at 3:09 pm #168873PorterParticipantI added my email above in a "set as private reply" post, did you get that?
I should actually only need your header.php file in this case, as I believe I have a php solution I can add there.
October 23, 2015 at 3:17 pm #168877handsunParticipant -
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.