$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>Adding specific custom fields (images) to post excerpt|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

Adding specific custom fields (images) to post excerpt

matteradmin8PV0评论

I am working on a simple user profile archive, using the theme "Atomic Blocks" as a starter theme. I am using one custom post type and several custom post fields to create these user profiles. The Custom Post type "Profile" and the plugin Advanced Custom Fields (ACF) to display different content on each "post" to look like a profile of sorts (a profile picutre, a file download, a video embed and short description).

Now I want to add more custom fields to these custom post type excerpts (see below). Mainly the profile pictures.,

I managed to create a custom excerpt that displays the profile description ("Profilbeschreibung" in the image above) custom field with this code:

function advanced_custom_field_excerpt() {
    global $post;
    $text = get_field('profilbeschreibung');
    if ( '' != $text ) {
        $text = strip_shortcodes( $text );
        $text = apply_filters('the_content', $text);
        $text = str_replace(']]>', ']]>', $text);
        $excerpt_length =30; // 30 words
        $excerpt_more = apply_filters('excerpt_more', ' ' . '[...]');
        $text = wp_trim_words( $text, $excerpt_length, $excerpt_more );
    }

    return apply_filters('the_excerpt', $text);
}

Since I am not that experienced with creating custom wordpress functions I am stuck. My main question would be: Is there any way to achieve displaying a custom field containing an image in each profile excerpt?

I know that excerpts have a hard time displaying html, so I am not sure.

I looked all over and found nothing for my specific case. I appreciate any insight into what I might have to do or what went wrong. Thanks!

Post a comment

comment list (0)

  1. No comments so far