• Resolved GermanKiwi

    (@germankiwi)


    Hi there,

    I’d like to have another crack at modifying the excerpt of my sermons, using a function as described here:
    https://wpforchurch.com/my/knowledgebase/69/Modifying-the-Excerpt-of-a-Sermon-Archive.html

    I tinkered around a bit with this about a year ago, and it worked well then, but it doesn’t seem to work anymore – the function I had created, based on the example on the above KB page, no longer seems to do anything. Maybe something has changed in the plugin since then.

    Incidentally, I also noticed that the KB article refers to at least two screenshots which are missing from the article. And the hyperlink for “Sermon Manager template tags KB article” (2nd-to-last paragraph) is broken. I think the KB article itself is quite old and probably needs an update!

    Can you kindly provide me with current steps or info on how to use a function to customise the excerpt, based on the current version of Sermon Manager?

    And I assume that using a function like this is still the recommended or preferable method for customising it?

    Thanks!

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

Viewing 8 replies - 1 through 8 (of 8 total)
  • Nikola

    (@nikolam)

    Hi @germankiwi,

    I apologize for our documentation being out of date, thank you for pointing it out.
    While we work on getting it updated, please use the following code. πŸ™‚

    add_action( 'wpfc_sermon_excerpt_v2', function ( $output, $post ) {
    	ob_start(); ?>
    
        <!-- The modified HTML goes here, or you can take the HTML from
         "includes/sm-template-functions", function named "wpfc_sermon_excerpt_v2()" -->
    
    	<?php return ob_get_clean();
    }, 10, 2 );
    
    Thread Starter GermanKiwi

    (@germankiwi)

    Great, thanks a lot!

    And there’s not a problem with this new function having the same name (wpfc_sermon_excerpt_v2) as the function it’s replacing? I thought functions had to have unique names, even if one is intended to override the other?

    Also, the next thing I want to tackle, after I modify the excerpt, is modifying the HTML of the “single post” page for each sermon. Is there a function similar to the above, which I can use to achieve that?

    Nikola

    (@nikolam)

    You are welcome!

    We are not overriding the function, we are just hooking into the filter in the function. (which is, incidentally, named exactly like the function)

    So, the code block that I have sent in my previous reply should just be put into (child) theme’s functions.php. With no additional code outside it.

    Regarding overriding single sermon, please change wpfc_sermon_excerpt_v2 to wpfc_sermon_single_v2, so the full code block would look like this:

    
    add_action( 'wpfc_sermon_single_v2', function ( $output, $post ) {
    	ob_start(); ?>
    
        <!-- The modified HTML goes here, or you can take the HTML from
         "includes/sm-template-functions", function named "wpfc_sermon_single_v2()" -->
    
    	<?php return ob_get_clean();
    }, 10, 2 );

    And this code block would go right after (or before – doesn’t matter) excerpt code block.

    Let us know if you have more questions. πŸ™‚

    Thread Starter GermanKiwi

    (@germankiwi)

    Okay that makes sense, re: hooking into a filter in the function. It sounds like a better way of doing it than the “old” method mentioned in the documentation, which – as far as I understood it – was to replace the entire function with a new function. This new method seems easier and cleaner to me. πŸ™‚

    I plan to work on these two things (excerpt and single) over the next couple of weeks. I’ll let you know if any further questions come up!

    Nikola

    (@nikolam)

    Yup, old method overrode whole function, this one just hooks into existing one – and it is cleaner in my opinion as well. πŸ™‚

    Sure, please do!
    By the way, you can access sermon’s WP_Post object with $post parameter (it is already there in code block from the previous replies). Also, the global $post will most likely be the same as $post function parameter, so you can use the_ID(), the_title(), etc…

    Also, if you get stuck, you can see how we gather data for excerpt and for single.

    Also, of course, you will need to create your own CSS rules if you modify the HTML structure. Sermon Manager’s CSS can be disabled in Sermon Manager Settings, “General” tab, “Disable Sermon CSS” option.

    Thread Starter GermanKiwi

    (@germankiwi)

    @nikolam, out of curiosity, when was the new method introduced, and the old method removed? Was it mentioned in the changelogs? I’m still using an older version of SM – I need to update that soon too – but want to make sure I’m not trying to use the new method on a version of SM that doesn’t support it.

    Nikola

    (@nikolam)

    The new method was introduced in development version of 2.10.1 (Dec 19, 2017) – see here. (That is the old filter, which is deprecated now (but it is still in code), and it’s not used by Sermon Manager anymore. The new filters were added in development version 2.12.0 (Feb 14th, 2018) – see here)
    And it had a minor notice in the changelog.

    Old method was removed in development version of 2.12.0 (Feb 14th, 2018) – see here.

    Thread Starter GermanKiwi

    (@germankiwi)

    Great, that’s very helpful!

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Modifying the Excerpt’ is closed to new replies.