Solved

Displaying custom field color picker value in inline style

Posted on 2015-02-03
5
138 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
ID: 40586657
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
ID: 40587054
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
ID: 40587916
?????
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
ID: 40588420
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
ID: 40597929
Figured it out myself
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
This video teaches users how to migrate an existing Wordpress website to a new domain.
The purpose of this video is to demonstrate how to exclude a particular blog category from the main blog page. This is can be used when a category already has its own tab, or you simply want certain types of posts not to show up on the main blog. …

777 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