We're merging with GenerateBlocks! Learn more here.

[Resolved] Displaying Sermon Manager meta in WP Show Posts?

Please login to receive premium support.

Support for the free plugin can be found here.

Home Forums Pro Support Displaying Sermon Manager meta in WP Show Posts?

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #13775
    Bodie J
    Participant

    I am absolutely loving WP Show Posts and want to use it to display sermon posts from the Sermon Manager plugin. I can get a good bit of info already but wanted to know the best way to tweak it. For example, if I wanted to show the speaker, how would I configure WP Show Posts to find that data? Would I use meta keys?

    Here is the sermon manger documentation that talks about pulling in different parts, and just wanted to see if I could get WP Show Posts to pull in some of the terms like Bible passage, Speaker, Service Type, etc.

    https://wpforchurch.com/my/knowledgebase/73/Template-Tags.html

    If I could get some basic direction on doing one, I could probably figure out how to get the rest from there.

    Thanks!

    #13795
    Tom
    Keymaster

    Hi there,

    It looks like they have wrapper functions for get_post_meta(), which is good.

    That way, you would just use the available hooks to add those functions into your lists.

    For example: https://wpshowposts.com/support/topic/custom-fields/#post-220

    #13832
    Bodie J
    Participant

    Great, Thanks Tom!

    Ok I found the code from the Sermon Manager plugin that I want to add into WPSP. Do I need all of this? It is a footer info so I was thinking of adding it into wpsp_after_content Is there anything you would do to modify it to work correctly?

    			<div class="wpfc-sermon-footer">
    				<?php if ( has_term( '', 'wpfc_preacher', $post->ID ) ) : ?>
    					<div class="wpfc-sermon-meta-item wpfc-sermon-meta-preacher">
    						<?php
    						echo apply_filters( 'sermon-images-list-the-terms', '', // phpcs:ignore
    							array(
    								'taxonomy'     => 'wpfc_preacher',
    								'after'        => '',
    								'after_image'  => '',
    								'before'       => '',
    								'before_image' => '',
    							)
    						);
    						?>
    						<span class="wpfc-sermon-meta-prefix">
    							<?php echo sm_get_taxonomy_field( 'wpfc_preacher', 'singular_name' ); ?>
    							:</span>
    						<span class="wpfc-sermon-meta-text"><?php the_terms( $post->ID, 'wpfc_preacher' ); ?></span>
    					</div>
    				<?php endif; ?>
    				<?php if ( get_post_meta( $post->ID, 'bible_passage', true ) ) : ?>
    					<div class="wpfc-sermon-meta-item wpfc-sermon-meta-passage">
    						<span class="wpfc-sermon-meta-prefix">
    							<?php echo __( 'Passage', 'sermon-manager-for-wordpress' ); ?>:</span>
    						<span class="wpfc-sermon-meta-text"><?php wpfc_sermon_meta( 'bible_passage' ); ?></span>
    					</div>
    				<?php endif; ?>
    				<?php if ( has_term( '', 'wpfc_service_type', $post->ID ) ) : ?>
    					<div class="wpfc-sermon-meta-item wpfc-sermon-meta-service">
    						<span class="wpfc-sermon-meta-prefix">
    							<?php echo sm_get_taxonomy_field( 'wpfc_service_type', 'singular_name' ); ?>:</span>
    						<span class="wpfc-sermon-meta-text"><?php the_terms( $post->ID, 'wpfc_service_type' ); ?></span>
    					</div>
    				<?php endif; ?>
    			</div>

    Would you be able to show me an example of how to properly add this into WPSP? The code from the previous post was

    add_action( 'wpsp_before_content','wpsp_add_custom_meta' );
    function wpsp_add_custom_meta()
    {
        $meta = get_post_meta( get_the_ID(), '_your_custom_meta_key', true );
        if ( isset( $meta ) && '' !== $meta )
            echo $meta;
    }

    So would it look like:

    add_action( 'wpsp_after_content','wpsp_add_sermon_manager_meta' );
    function wpsp_add_sermon_manager_meta()
    {
    <div class="wpfc-sermon-footer">
    				<?php if ( has_term( '', 'wpfc_preacher', $post->ID ) ) : ?>
    					<div class="wpfc-sermon-meta-item wpfc-sermon-meta-preacher">
    						<?php
    						echo apply_filters( 'sermon-images-list-the-terms', '', // phpcs:ignore
    							array(
    								'taxonomy'     => 'wpfc_preacher',
    								'after'        => '',
    								'after_image'  => '',
    								'before'       => '',
    								'before_image' => '',
    							)
    						);
    						?>
    						<span class="wpfc-sermon-meta-prefix">
    							<?php echo sm_get_taxonomy_field( 'wpfc_preacher', 'singular_name' ); ?>
    							:</span>
    						<span class="wpfc-sermon-meta-text"><?php the_terms( $post->ID, 'wpfc_preacher' ); ?></span>
    					</div>
    				<?php endif; ?>
    				<?php if ( get_post_meta( $post->ID, 'bible_passage', true ) ) : ?>
    					<div class="wpfc-sermon-meta-item wpfc-sermon-meta-passage">
    						<span class="wpfc-sermon-meta-prefix">
    							<?php echo __( 'Passage', 'sermon-manager-for-wordpress' ); ?>:</span>
    						<span class="wpfc-sermon-meta-text"><?php wpfc_sermon_meta( 'bible_passage' ); ?></span>
    					</div>
    				<?php endif; ?>
    				<?php if ( has_term( '', 'wpfc_service_type', $post->ID ) ) : ?>
    					<div class="wpfc-sermon-meta-item wpfc-sermon-meta-service">
    						<span class="wpfc-sermon-meta-prefix">
    							<?php echo sm_get_taxonomy_field( 'wpfc_service_type', 'singular_name' ); ?>:</span>
    						<span class="wpfc-sermon-meta-text"><?php the_terms( $post->ID, 'wpfc_service_type' ); ?></span>
    					</div>
    				<?php endif; ?>
    			</div>
    }

    Love to know your thoughts!

    Thanks

    #13836
    Bodie J
    Participant

    Oh wow, this definitely doesn’t work! Ha ha. I remembered the cardinal rule: NO HTML inside PHP. I definitely can replicate patterns if I can get one meta term to work. Thanks for any direction!

    #13875
    Tom
    Keymaster

    You can add HTML inside PHP, you just need to close the PHP part first:

    add_action( 'wpsp_after_content', function() {
        ?>
            HTML in here.
        <?php
    } );
    #13879
    Bodie J
    Participant

    Oh, ok! Thanks for the response, Tom.

    So is the reason the code above doesn’t work because the <div class="wpfc-sermon-footer"> that begins and ends the code block is outside of the PHP tags?

    #13881
    Bodie J
    Participant

    Nevermind, I got it!! Thanks so much Tom. I didn’t realize that code was ready to go, I at first glance thought I had to write a function name, but no! function() was to be left as is. This is so great, thanks again.

    add_action( 'wpsp_after_content', function() {
        ?>
            <div class="wpfc-sermon-footer">
    				<?php if ( has_term( '', 'wpfc_preacher', $post->ID ) ) : ?>
    					<div class="wpfc-sermon-meta-item wpfc-sermon-meta-preacher">
    						<?php
    						echo apply_filters( 'sermon-images-list-the-terms', '', // phpcs:ignore
    							array(
    								'taxonomy'     => 'wpfc_preacher',
    								'after'        => '',
    								'after_image'  => '',
    								'before'       => '',
    								'before_image' => '',
    							)
    						);
    						?>
    						<span class="wpfc-sermon-meta-prefix">
    							<?php echo sm_get_taxonomy_field( 'wpfc_preacher', 'singular_name' ); ?>
    							:</span>
    						<span class="wpfc-sermon-meta-text"><?php the_terms( $post->ID, 'wpfc_preacher' ); ?></span>
    					</div>
    				<?php endif; ?>
    				<?php if ( get_post_meta( $post->ID, 'bible_passage', true ) ) : ?>
    					<div class="wpfc-sermon-meta-item wpfc-sermon-meta-passage">
    						<span class="wpfc-sermon-meta-prefix">
    							<?php echo __( 'Passage', 'sermon-manager-for-wordpress' ); ?>:</span>
    						<span class="wpfc-sermon-meta-text"><?php wpfc_sermon_meta( 'bible_passage' ); ?></span>
    					</div>
    				<?php endif; ?>
    				<?php if ( has_term( '', 'wpfc_service_type', $post->ID ) ) : ?>
    					<div class="wpfc-sermon-meta-item wpfc-sermon-meta-service">
    						<span class="wpfc-sermon-meta-prefix">
    							<?php echo sm_get_taxonomy_field( 'wpfc_service_type', 'singular_name' ); ?>:</span>
    						<span class="wpfc-sermon-meta-text"><?php the_terms( $post->ID, 'wpfc_service_type' ); ?></span>
    					</div>
    				<?php endif; ?>
    			</div>
        <?php
    } );
    #13924
    Tom
    Keymaster

    Glad I could help! 🙂

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