Solved

Displaying custom field color picker value in inline style

Posted on 2015-02-03
5
132 Views
Last Modified: 2015-02-09
Hi,
I have setup a custom color picker field called "title_colour" which i have placed inline style on a <h2> tag, however its not displaying the hex value on the front end. This is the code im using:

<h3 style="color:<?php the_field('title_colour');?>">Notice Board</h3>

This is the results showing when i inspect the element:

<h3 style="colour:">Notice Board</h3>

This is the link i got the code from

http://www.advancedcustomfields.com/resources/color-picker/

Is there something im doing wrong?

Thanks,
Andrew
0
Comment
Question by:Andy6350
  • 3
  • 2
5 Comments
 
LVL 33

Expert Comment

by:Slick812
Comment Utility
you need to tell PHP to push out that string to output with the echo command -

<h3 style="color:<?php echo the_field('title_colour');?>">Notice Board</h3>

and there must be a string in the-  the_field('title_colour');
0
 

Author Comment

by:Andy6350
Comment Utility
I have changed the code using the echo command above but it still doesn't appear. There are no specific options in ACF color picker so im assuming its generating a hex string ie #ffffff

Is there any other code i need to include?

Thanks,
Andrew
0
 
LVL 33

Expert Comment

by:Slick812
Comment Utility
?????
I have never used the AFC color picker, so I can not say what to do, sorry, but I looked and could not find The developers API for this AFC color picker. I did find this for code examples, but it's useless to me? -
http://www.advancedcustomfields.com/resources/code-examples/
0
 

Accepted Solution

by:
Andy6350 earned 0 total points
Comment Utility
Hi,

I worked it out. Realised that it wasn't pulling through the custom field value because the custom field was on the post page its pulling through on the home page, added the custom field to the home page and it worked.

Thanks for you help.

Andrew
0
 

Author Closing Comment

by:Andy6350
Comment Utility
Figured it out myself
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

WordPress can be pretty daunting, especially for a beginner, so I thought it might be a good idea to write an article to show how easy it is to get started in WordPress and to design a custom theme.  The first step is to check with your hosting comp…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The purpose of this video is to demonstrate how to set up an RSS Feed on a WordPress Website. This will be demonstrated using a Windows 8 PC. Feedburner will be used for this demonstration. Go to your WordPress login page. This will look like the…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now