[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Displaying custom field color picker value in inline style

Posted on 2015-02-03
5
Medium Priority
?
158 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
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. …
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.
Suggested Courses

650 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