-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using fields #45
Comments
I need help with this too. |
I forked this repo fixed some bugs and added onto it on my bitbucket. I'll post a link later on tonight.
|
@panarican Wonderful. Does it explain how to output Images and the rest of the field types as well? Thanks for your time. |
I've managed to get the image data: Still need help with the other field types though...will be checking forum later today for link :) |
Here's my repo that contains bug fixes and template helper functions Here's a link to the template helper functions: Repeatable Example (I hope this helps): // use this inside your loop it will give u a preview of how all your meta data looks inside your post
pre_meta();
// let's say you have a field name of photos_images that's repeatable
// and you want to get the the field image "img" inside of the repeatable group
$photosImages = get('photos_images');
// make a foreach
foreach($photosImages as $item) {
// $item would be the individual item inside of the $photosImages array
// to get the field with the name "img" associated with it
$img = $item['img'];
// to output the repeated img you can do something like this
// the first parameter is the id of the image attachement
// the second parameter is an array of the size of the image
echo img( $img , array(107,62) );
} |
@panarican hmm...with my poor skill in any of this, I could not understand anything within the files you linked to. I just wanted to figure out how to display the data from fields on a page template, that's all. |
OK you can do the following: You can copy all the functions on template.php file I linked too then The snippet should still work just by doing that. If you have any questions
|
@panarican thanks for the feedback, I was able to out put all the info like so: $prefix = 'MA_'; $music_options = array(
It outputs each track as a ul list, hope this helps. |
@rliriano I'm still not comprehending :/ Do you place that whole function inside of your page template? Or within functions.php? Please help.. |
@keihead can u post your array you used to generate your custom meta box?
|
@panarican No problem :)
|
Inside your while loop do this. <?php
$tracks = get_post_meta($post->ID, 'album_repeatable', true);
foreach($tracks as $track) { ?>
<div class="track">
<h2><?php echo $track['title']; ?></h2>
<div class="featuring"><?php echo $track['featuring']; ?></div>
<div class="producer"><?php echo $track['producer']; ?></div>
<div class="mp3"><a href="<?php echo $track['mp3']; ?>" target="_blank">Download MP3</a></div>
</div>
<?php
} ?> |
@panarican THANK YOU VERY MUCH :D Works wonderfully!!! I have one last question if you have time... For other fields like Select Menu, Slider, Checkboxes etc. do I display the data with a similar code as you provided above? |
If the field isn't an array of items (like a repeatable field). Then it would most likely be. <?php $field = get_post_meta($post->ID, 'field_name', true); ?>
<div class="field"><?php echo $field; ?></div> |
You're Welcome 👍 |
Could you please add how to output the repeatable fields on a page.
Thanks
The text was updated successfully, but these errors were encountered: