- This topic is empty.
-
AuthorPosts
-
April 17, 2013 at 11:14 am #44168
JokerMartini
ParticipantHey guys. I’m trying to style the metaData from a wordpress post. I need to make a for loop that goes through all the meta data (if there is some) and style it as follows
(CUSTOME FIELD NAME GOES HERE)(CUSTOME FIELD VALUE GOES HERE)April 17, 2013 at 11:22 am #132144Paulie_D
MemberSo what is your question?
How to style it…or how to achieve the loop?
April 17, 2013 at 11:32 am #132145JokerMartini
ParticipantHow to achieve the loop and style it?
April 17, 2013 at 11:34 am #132146pixelgrid
Participantget post meta is your friend http://codex.wordpress.org/Function_Reference/get_post_meta
simple use
and then you get each field from its name saved
you can read how to set the meta boxes here
April 17, 2013 at 11:38 am #132150JokerMartini
ParticipantI’m not exactly sure to how write the for loop and add in my styling divs for the name a value. Could someone help me do that?
April 17, 2013 at 11:57 am #132153pixelgrid
Participant
the code will work for as many post as you have queried and have these meta keys
April 17, 2013 at 11:58 am #132154JokerMartini
ParticipantAwesome. Thank you very much for the help on this. It’s a keeper for sure.
April 17, 2013 at 12:25 pm #132076JokerMartini
ParticipantThat didn’t quite work out. It went haywire and listed the post hundreds and hundreds of times.
I want to take each custom field entry and style it. http://jokermartini.com/myStuff/temp.jpg
customfield NAME goes in div class=”detailTitle”>NAME /div
customfield VALUE goes in div class=”detailValue”>VALUE /divfor each custom item on this project/post do…..
div class=”projectDetails”
div class=”detailTitle”>NAME /div
div class=”detailValue”>VALUE /div
/divThis forloop is going on my Single.php
April 17, 2013 at 12:27 pm #132155pixelgrid
Participantwhat plugin are you using to add the custom fields?
April 17, 2013 at 12:28 pm #132156JokerMartini
ParticipantNothing. I using the standard one that comes with wp
April 17, 2013 at 12:29 pm #132157pixelgrid
Participantalso to the bottom there is a link saying use them in your theme. did you mind pressing it? im sure it has instructions how to do it
April 17, 2013 at 12:33 pm #132158pixelgrid
Participantin my code you have to replace the ‘custom_field_1_name’ with ‘Authors’ and the second line to ‘Studio’ did you do that?
April 17, 2013 at 12:53 pm #132160JokerMartini
Participantalright ill check that out.
Thank youApril 17, 2013 at 12:54 pm #132161JokerMartini
ParticipantNo I didn’t do that. I wanted it to automatically just continue going through however many custom fields there were.
April 17, 2013 at 1:01 pm #132163pixelgrid
Participant
foreach ($meta as $key => $value){ ?>
try this one
-
AuthorPosts
- The forum ‘CSS’ is closed to new topics and replies.