Forum Replies Created
-
AuthorPosts
-
SteveKeymaster@Marc– Welcome to the Piklist community!
We had a long list of items to add to the comment block, including class, but we decided to go in another direction since the list was growing every week.
In the next version of Piklist you will be able to add your own custom parameters to the comment block. So
classormarcs classor anything else you want can be added.
SteveKeymaster@ehime– Welcome to the Piklist community!
Your code is very close. The last array is telling Piklist what to save and what to display. You are saving the
IDand displaying thetitle. These parameters should relate directly with your WP database table. You can see the schema here.There is no field
titlein thewp_poststable, the actual field ispost_title.Change the last part of your code to this and it should work:
,array( 'ID' ,'post_title' )
SteveKeymaster@jcrist– On our list of todos. We wanted to first get the server-side validation solid because it’s more secure.
SteveKeymaster@spitfire– The idea behind these enhanced meta queries was to speed up your site and allow Piklist to do some amazing things in the future. I just emailed you the latest version of our beta which fixes the issues with the queries and provides a checkbox for you to opt in.
Also, just to be clear, if you opt in you will see additional queries… but your site should also see a performance improvement. Though there will be more queries they are better optimized then the default WordPress meta queries. $more_queries !== $slower_site.
SteveKeymaster@ianmuscat– I suggest you get it working properly with the standard WordPress function. Then you can port it over to us the Piklist filter if you like.
SteveKeymasterBoth fixed. Thanks!
April 20, 2015 at 10:29 am in reply to: Front End Call data from Piklist Group with Specific Page ID #3645
SteveKeymaster@liquidws– Sorry for the delayed response.
IMPORTANT: Piklist does everything the WordPress way. You don’t have to rely on Piklist documentation to display post meta. Any WordPress tutorial on post meta would help you.
1) You’re using
get_poststo retrieve your post data which is fine, except this function does not retrievepost_meta, which you need. So$post->slide1_titledoes not exist.2) You can easily see what is being returned by a function by using the standard PHP function
print_r, or the Piklist functionpiklist::pre(). The Piklist function is just a prettier version ofprint_r.
Either one of these would show you what get_posts was returning:$posts = get_posts(array( 'post_type' => 'page', 'page_id' => 2 )); print_r($posts); piklist::pre($posts);3) To retrieve post_meta, just use the standard WordPress function get_post_meta.
4) When using the Piklist file field, the data that is saved is the Attachment ID, which WordPress automatically creates. Then you need to use this ID to retrieve the data you need. Since you can upload multiple files, Piklist saves all the IDs, and you need to loop through them to get the information you want. This tutorial explains it.
Here is your new code based on what I wrote above. Please let me know if something does not make sense.
foreach($posts as $post) { $url = get_post_permalink($post->ID); ?> <h2><?php the_title(); ?></h2> <img class="img-responsive" src="http://placehold.it/1280x250/16a085/ffffff&text=Page"/> <h3 style="color:#fff"><?php echo get_post_meta($post->ID, 'slide1_title', true); ?></h3> <?php // Get all the slide1_image IDs and then loop through them $slide1_image_ids = get_post_meta($post->ID, 'slide1_image', true); ?> <?php foreach ($slide1_image_ids as $image_id) : ?> <img class="img-responsive" src="<?php echo wp_get_attachment_url($image_id); ?>"/> <?php endforeach; ?> <?php echo get_post_meta( $post->ID, 'slide1_description', true ); ?> <?php // Get all the slide1_select_page_links IDs and then loop through them $slide1_select_page_links = get_post_meta($post->ID, 'slide1_select_page_link', false); ?> <?php foreach ($slide1_select_page_links as $page_link) : ?> <a href="<?php echo get_permalink($page_link); ?>" target="_blank">website</a> <?php endforeach; }
SteveKeymaster@liquidws– In most cases the “scope” of the field is the database table you are saving it to. You are setting the scope to “post”, which is the WordPress posts table… wp_posts. Which is fine, if you use any of the fields WordPress allows. Which in your case would probably be post_content or post_excerpt. But you are saving it to a custom field, careers_description, which is not allowed in wp_posts… but is allowed in wp_postmeta.
Just remove the
scopeparameter and Piklist will figure it out and save it properly.You can see the full WordPress database schema here >
SteveKeymasterGreat. Closing ticket.
SteveKeymaster@ravinder123– Welcome to the Piklist community!
This is actually quite difficult to achieve. We’re adding this to our list of todos, but for now we recommend you doing it with the standard WordPress code. Sorry we couldn’t be more helpful on this one.
SteveKeymasterGreat. Closing ticket.
SteveKeymaster@Gregg– Glad it works for you. Closing ticket.
SteveKeymaster@hirschbrat– Try these two hooks and see if they work for you:
WordPress: updated_{$meta_type}_meta
Piklist:piklist_save_fieldin class-piklist-form.php
SteveKeymaster@hirschbrat– It’s not as fancy as you think. We just pulled in the fields, added them up, and displayed the sum.
SteveKeymaster@Gregg– You can use inline CSS in your theme’s
. Try something like this in your theme’sfunctions.phpfile:add_action('wp_head', 'my_custom_css'); function my_custom_css() { $options = get_option('YOUR-OPTION-NAME'); ?> <style type="text/css"> html { background-color: <?php echo $options['background-color']; ?>; } </style> <?php } -
AuthorPosts