Support » Plugin: Pods - Custom Content Types and Fields » How to get excerpts to work using PODS

  • Resolved bryanhiggs

    (@bryanhiggs)


    I am using PODS in the OceanWP theme, and Elementor on WordPress 5.0.3

    My understanding of how excerpts are generated is summarized in the following article: https://kinsta.com/knowledgebase/wordpress-excerpt/ . Basically, as I understand it, if my theme supports excerpts (and I believe OceanWP does), I can generate an excerpt in three ways:

    • By letting WordPress produce an excerpt by extracting the first 50 words of the description.
    • By inserting a More tag using the editor
    • By manually writing an excerpt

    So, using my “UUCM Services” Pod, I am displaying the next service in a Elementor widget on the front page of my site. Because of limited space, I would like to show the excerpt. I also display forthcoming services on a page; here I would like to display the entire description (https://play.uucm.org/ministries/upcoming-uucm-services-2/).

    I basically have it all working, except for one thing: How to extract excerpts for the front page widget. I am using the PODS {@post_excerpt} field in the corresponding template. It only seems to work if I manually generate an excerpt (i.e., I enable the excerpt field and enter something into it.) I have tried the other two methods (first 50 words, and using a More tag, together with disabling the manual excerpt field) and nothing gets returned.

    Given that it’s annoying and error-prone to have to manually supply an excerpt, how can I fix this problem?

    Thanks for any insight/help/guidance you can give me!

    The page I need help with: [log in to see the link]

Viewing 9 replies - 1 through 9 (of 9 total)
  • I have just added a page to the above website. It replicates the query {PODS shortcode) to list all upcoming services, except that instead of showing the description, it shows the extract. Only those services where an explicit, manually created extract exists show any partial content. Here it is: https://play.uucm.org/upcoming-uucm-services-summary/

    Plugin Author Jim True

    (@jimtrue)

    The {@post_excerpt} magic tag in Pods doesn't run through thethe_excerptfilter and function, https://developer.wordpress.org/reference/functions/the_excerpt/. Thepost_excerpt` is the actual field in the wp_posts table.

    When you modify your post type to support ‘post excerpt’, it adds that manual input excerpt field. the_excerpt filter (which is what your theme uses) shows either that manual excerpt or runs your post_content against the_excerpt filter. That is all theme based, unfortunately, so we can’t help you there. If you setup your dynamic content to point to the field post_excerpt, you will only <em>ever</em> get the contents of the post_excerpt (the manual excerpt) in the database.

    You would need to reach out to your Elementor Pro support to show the_excerpt filter instead. That’s a standard function of the theme against ‘posts’ so it should be pretty straightforward and displaying that would be handled naturally by Elementor Pro, not by us.

    If you’re using our Pods Template then you want to do an [if post_excerpt]{@post_excerpt}[else]{@post_content}[/if] and that would show either the manually entered post_excerpt or post_content. You could additional feed post_content into another function that would substr just to the first so many characters (basically the same thing as a custom excerpt function), using our magic tag ‘filter’ of {@post_content,my_excerpt_filter} it just needs to take content as input and return the content trimmed down:

    
    function my_excerpt_filter ( $content ) {
       return wp_trim_words( $content, 20 );
    }
    

    (from this article: https://www.lockedownseo.com/custom-excerpt-length-in-wordpress/)

    WOW! Jim, you are so helpful! This sounds like just what I need. Thanks!

    One question: I presume that I supply the my_excerpt_filter function that you show? Where do you suggest I put it? in the PODS template within a <php> tag?

    (Sorry if this is a dumb question.)

    Plugin Author Jim True

    (@jimtrue)

    Not a dumb question at all. You would add it to the functions.php of your child theme or you can use Code Snippets pluginto insert it as well.

    I used the Code Snippets plugin, and it worked like a charm!

    Thanks a bunch, Jim!

    Jim, I must commend you for your great support! It’s been the most responsive and most useful I’ve experienced with WordPress plugins.

    Keep up the good work!

    Plugin Author Jim True

    (@jimtrue)

    Thank you! That’s very kind 😉

    Plugin Author Scott Kingsley Clark

    (@sc0ttkclark)

    That’s awesome feedback, thanks so much! I am so proud to have Jim doing all that he does for Pods!

    Credit where credit is due!

Viewing 9 replies - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.