Display custom fields issue
-
Hi, great plugin. Having trouble bringing custom child page fields into a custom parent page template, can’t figure out why they don’t display, probably something stupid I’m doing/not doing. I’m using a modification of your “Further Customization for Adding Custom Fields” code on Github (https://gist.github.com/1209601). Here is the page I’m working on: https://test.dvcdrama.net/about-us/facultystaff/ – built on Genesis/Metro Pro. Will add to functions.php, once it’s debugged.
Here is the shortcode:
[display-posts post_type=”page” posts_per_page=”15″ post_parent=”current” image_size=”medium” faculty_title=”true” faculty_email=”true” include_excerpt=”true” order=”ASC” orderby=”menu_order” wrapper=”div”]Here is the modded version of your code:
add_filter( 'display_posts_shortcode_output', 'be_display_posts_custom_fields', 10, 6 ); function be_display_posts_custom_fields( $output, $atts, $image, $title, $date, $excerpt ) { // Get our custom fields global $post; $faculty_title = esc_attr( get_post_meta( $post->ID, 'faculty_title', true ) ); $faculty_email = esc_attr( get_post_meta( $post->ID, 'faculty_email', true ) ); // If there's a value for the custom field, let's wrap them with <span>'s so you can control them with CSS if( isset( $atts['faculty_title'] ) && "true" == $atts['faculty_title'] ) echo '<span class="dvcdrama-faculty-title">' . $faculty_title . '</span> '; if( isset( $atts['faculty_email'] ) && "true" == $atts['faculty_email'] ) echo '<span class="dvcdrama-faculty-email">' . $faculty_email . '</span> '; // Now let's rebuild the output. $output = '<div class="metro-pro-dvcdrama-facultystaff listing-item">' . $image . $title . $faculty_title . $faculty_email . $date . $excerpt . '</div>'; // Finally we'll return the modified output return $output; }
https://www.ads-software.com/plugins/display-posts-shortcode/
- The topic ‘Display custom fields issue’ is closed to new replies.