Forums › Forums › Search & Filter Pro › Custom field (Advanced custom field) in results
- This topic has 5 replies, 2 voices, and was last updated 8 years, 7 months ago by Trevor.
-
Anonymous(Private) April 8, 2016 at 9:58 pm #42111
Hi.
I’m purchase search & filter pro, and this is absolutely amazing.
But i need any things.
1-) Is possible print custom field of custom post type in results? I try this code, but dont work in results.php from template folder:<?php while ($query->have_posts()) { $query->the_post(); ?> <div> <h4><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4> <p><?php the_excerpt(); ?> <?php $post_object = get_field('pastilha_dianteira'); if( $post_object ): // override $post $post = $post_object; setup_postdata( $post ); ?> <?php the_field('numeracao_pastilha'); ?> </div> <?php wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly ?> <?php endif; ?> </div> <hr /> <?php } ?>
Any suggestion?
2-) I need in results the taxonomies from that result. Example:
TITLE OF POST – Taxonomy 1, Taxonomy 2, Taxonomy 3
Content
What’s code for it?Sorry for english.
Cheers.
Trevor(Private) April 9, 2016 at 9:48 am #42130Hi Guilherme
No need for apologies over language, with your name, maybe you speak Portuguese? sadly, I do not 🙁 It is good to see you here, so welcome 🙂
IF I understand you correctly (I hope that I do), then I know that, with the theme I normally use, this is possible, but with some coding. I do not know which theme you use, but coding WILL most probably be necessary. You seem to accept this, showing us your coding so far. Let us deal only with Q1 now, and then deal with Q2 after resolving Q1?
What theme are you using, what Display Results method are you using?
Trevor(Private) April 12, 2016 at 11:17 am #42423Light Bulb!!!!!
What you need is the list of terms, nicely formatted, but you can start your search in the WordPress Codex here:
https://codex.wordpress.org/Function_Reference/wp_get_post_terms
You can start by using one of the examples at the bottom and simply using print_r to list out the array of terms (each post taxonomy can have multiple taxonomy terms attached so the results are an array, but you can use the array splitting tools of PHP to make some nice HTML of them once you have confirmed you get the correct terms showing).
There will likely be further coding examples on StackOveflow’s WordPress coding forums.
-
AuthorPosts