Empty span? Advanced Custom Field import error
-
Hi,
I have added a image field to my CPT called posts and I’m now trying to display the image with the display posts shortcode, but can’t get it to work. What’s wrong?
I found this https://gist.github.com/billerickson/1209601 and when I tried using it, the span appears, but there is no content inside the span. My image field is named “erbjudandepuff”.
This is my 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; $erbjudandepuff = esc_attr( get_post_meta( $post->ID, 'erbjudandepuff', 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( $erbjudandepuff ) ) $erbjudandepuff = '<img class="erbjudandepuff" src="' . $erbjudandepuff . '" />'; // Now let's rebuild the output. $output = '<li><span class="right">' . $image . $erbjudandepuff .'</span>' . $title . $date . $excerpt . '</li>'; // Finally we'll return the modified output return $output; }
I added this in the functions.php
Any help in whats going wrong would be greatly appreciated!
Thanks!
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Empty span? Advanced Custom Field import error’ is closed to new replies.