NoSuperman Posted June 18, 2012 Share Posted June 18, 2012 I'm currently using Advanced Custom Fields to create a custom field has_the_portrait_sold which will be indicated on my Prettyphoto / Lightbox item. However, when I use PHP from the example (it is true or false): `<?php if(get_field('has_the_portrait_sold')){ echo "<img src="imagesold.png">"; }else{ echo "<img src="imagenotsold.png">"; } ?>` I tried to include this in header.php: `<script type text/javascript> jQuery(document).ready(function($) { $("a[href$='.jpg'], a[href$='.jpeg'], a[href$='.gif'], a[href$='.png']").prettyPhoto({ theme: 'dark_square', show_title: true, /* true/false */ social_tools: '<?php the_title(); ?> <?php if(get_field('has_the_portrait_sold')){ echo "<img src="imagesold.png>"; }else{ echo "<img src="imagenotsold.png"; } ?>' }); }); </script>` However, while this may include the custom field in the lightbox as needed, it apparently only displays custom field data for the current page. I am needing custom field data to print for the current lightbox item / WordPress' image attachment. I therefore tried including the custom field call in post-template.php. Please note my PHP skills are limited, I am VERY determined to make this work. `return apply_filters( 'wp_get_attachment_link', "<a title='$post_title' href='$url'>$link_text</a><?php if(get_field('has_the_portrait_sold')){ echo "do something"; }else{ echo "do something else"; } ?>", $id, $size, $permalink, $icon, $text ); }` I feel like I am on the right path in including the custom field call in post-template.php . However, I just do not have the PHP skills necessary to create the correct call. I'm wondering if someone here can help. I am very desperate, but not willing to give up. Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/264368-trying-to-combine-wordpress-prettyphoto-and-custom-fields-im-losing-my-mind/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.