Having a bit of a problem, i’m using ACF for WordPress, i have defined the color picker on the services template which color codes the page heading in a color you select. This template then has a page link which relates to another template: case studies – the case studies template has a select option where you select the page from services that relates to the case study. I can get those values out as it is on the case studies template. How do i go about getting the color picker value from the services page and apply the color to the case studies page? Here is what i have done so far;
<div class="caseStudies">
<h1 class="pageTitle uppercase"><?php echo the_title(); ?></h1>
<div class="caseStudyIntro"><?php echo the_content(); ?></div>
<?php
foreach($caseStudyChildren as $caseStudies)
{
$cStudyId = $caseStudies->ID;
$cStudyThumbnail = get_field("thumbnail_image", $cStudyId);
$cStudyRelation = get_field("case_study_relation", $cStudyId);
$cStudyContent = get_field("case_study_content", $cStudyId);
?>
<div class="caseStudyItem">
<div class="col-md-3 noPaddingLeft">
<a href="<?php echo get_permalink($cStudyId); ?>">
<img src="<?php echo $cStudyThumbnail['url']; ?>" alt="<?php echo $cStudyThumbnail['alt']; ?>" class="img-thumbnail cStudyThumb" />
</a>
</div>
<div class="col-md-9 noPadding">
<div class="content">
<h1 class="title uppercase">
<a href="<?php echo get_permalink($cStudyId); ?>" class="dark-black">
<?php echo get_the_title($cStudyId); ?> <?php echo '- '.$cStudyRelation; ?>
</a>
</h1>
<div class="study">
<?php echo wp_trim_words($cStudyContent, 40, '...'); ?>
</div>
<a href="<?php echo get_permalink($cStudyId); ?>" class="readMore red uppercase">Read More...</a>
</div>
</div>
</div>
<div class="clearfix"></div>
<?php
}/* foreach end */?>
</div>
This line here is where i am adding the services link that relates to the case study (so it almost acts like a tag)
<?php echo get_the_title($cStudyId); ?> <?php echo '- '.$cStudyRelation; ?>
Backend Configuration
Hope that made some sense, if not let me know and i can add to it more. PHP newbie here so go easy one me, haha!
Thanks.
Managed to figure this out in the end. I’ve got the relationship to the page coming out now and now i’ve got the color custom field that was defined on the services template coming out on the case studies page.
So i defined the field name in a variable;
Then did the following;
So built up the array for the color field created in ACF and then echoed that out against the ID the case study was related to. Hope that makes sense! Not the best at explaining stuff as you can tell.
The last piece of the jigsaw was to apply the color value against the page relationship page title;
Thank you to those that have taken the time out to contribute to this question.