WordPress.org

Ready to get started?Download WordPress

Forums

List category posts
Advanced Custom Fields in List category posts excerpt (3 posts)

  1. end3r.w
    Member
    Posted 1 year ago #

    I've been having issue with this for the past two weeks.

    Does anyone know how to to this ?

    i found solution to show advanced custom fields excerpt in category posts view and on single post, but had no luck in showing it on list category posts excerpt.

    this is the solution i found on with regards to displaying excerpt :

    http://wordpress.org/support/topic/how-to-pull-excerpt-from-advanced-custom-field?replies=32

    putting this in fuction.php :

    function custom_field_excerpt() {
    global $post;
    $text = get_field('field_name');
    if ( '' != $text ) {
    $text = strip_shortcodes( $text );
    $text = apply_filters('the_content', $text);
    $text = str_replace(']]>', ']]>', $text);
    $excerpt_length = 20; // 20 words
    $excerpt_more = apply_filters('excerpt_more', ' ' . '[...]');
    $text = wp_trim_words( $text, $excerpt_length, $excerpt_more );
    }
    return apply_filters('the_excerpt', $text);
    }

    putting this inside loop.php
    <?php echo custom_field_excerpt(); ?>

    if i put this under single blog post in loop it works, if i put this inside blog posts loop it doesnt show it.

    Does anyone have solution for this ? am i putting this inside wrong file ?

    http://wordpress.org/plugins/list-category-posts/

  2. 1000wordsmedia
    Member
    Posted 1 month ago #

    I am no expert on this here, and not sure if found an answer, but I think that since this is a plugin and they write their own custom functions that work in tandem with their plugin that you would need to write this code in the plugin and not the functions.php file. Doing it at the theme level won't help you in the shortcode understanding what you are telling the theme to do better.

  3. 1000wordsmedia
    Member
    Posted 1 month ago #

    I am looking into doing the same thing and found that the file you would need to add this theme function to is named CatListDisplayer.php inside editing the plugin. Again I know little about this, so there might be a more direct way of doing this that is safer along the way, like making something similar to a child plugin of some sort, if that is even done.

    you wuld also need ot add the function name into the shortcode list in the list_cat_posts.php file.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic