Custom fields on Qeury
-
Am using a DATE field for a custom post type (events) (both created via your plugin).
Am trying to display a list of events with custom field displayed as well, using “display posts plugin“.
Am using the following code as guided by the plugin author herefunction be_dps_include_event_date( $output, $original_atts, $image, $title, $date, $excerpt, $inner_wrapper, $content, $class, $author, $category_display_text ) { if( empty( $original_atts['include_event_date'] ) || false === filter_var( $original_atts['include_event_date'], FILTER_VALIDATE_BOOLEAN ) ) return $output; $key = 'field_3d0p5'; //this is the field from your plugin. $event_date = get_post_meta( get_the_ID(), $key, true ); if( empty( $event_date ) ) return $output; // Convert to formatted date. // See: https://www.ads-software.com/support/article/formatting-date-and-time $event_date = date( 'F j, Y', $event_date ); // Add span around it for styling $event_date = '<span class="event-date">' . $event_date . '</span>'; // Insert it into the output wherever you'd like it $output = '<' . $inner_wrapper . ' class="' . implode( ' ', $class ) . '">' . $image . $title . $event_date . $date . $author . $category_display_text . $excerpt . $content . '</' . $inner_wrapper . '>'; return $output; } add_filter( 'display_posts_shortcode_output', 'be_dps_include_event_date', 10, 11 );
But out put is not showing the custom field. What am i doing wrong? Is the key wrong?
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Custom fields on Qeury’ is closed to new replies.