Solved

Displaying custom field color picker value in inline style

Posted on 2015-02-03
5
143 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 34

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 34

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
In order to have all security and back ups taken care of, WordPress users can sign up for services with WP Engine.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

740 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