Jump to content

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


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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.