AFC custom field conditional not working
-
Hello Bill Erickson thanks for this awesome plugin.
I have the next question, i’ve created a custom field (AFC) for a custom post type, for to add that custom field, I add this code to my functions.php
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; $testimonio = esc_attr( get_post_meta( $post->ID, 'video_en_vimeo', 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( $testimonio ) ) { $testimonio = "<iframe src=" . $testimonio . '" width="100%" height="300" frameborder="0" allowfullscreen="allowfullscreen" /></iframe>'; // Now let's rebuild the output. $output = '<li><span class="right">' . $image . $testimonio .'</span>' . $title . $date . $excerpt . '</li>'; // Finally we'll return the modified output return $output; } else { return $output; } }
The code works but it appears in all the shortcodes, the conditional is bad?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘AFC custom field conditional not working’ is closed to new replies.