Jump to content

Trying to combine WordPress, Prettyphoto and Custom fields.. I'm losing my mind!


NoSuperman

Recommended Posts

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.