Home › Forums › Pro Support › Displaying Sermon Manager meta in WP Show Posts?
Tagged: meta, Sermon Manager
- This topic has 7 replies, 2 voices, and was last updated 3 years, 8 months ago by
Tom.
-
AuthorPosts
-
March 7, 2020 at 1:00 am #13775
Bodie J
ParticipantI 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!
March 7, 2020 at 7:57 pm #13795Tom
KeymasterHi 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
March 8, 2020 at 9:05 pm #13832Bodie J
ParticipantGreat, 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
March 9, 2020 at 10:32 am #13836Bodie J
ParticipantOh 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!
March 10, 2020 at 6:04 pm #13875Tom
KeymasterYou can add HTML inside PHP, you just need to close the PHP part first:
add_action( 'wpsp_after_content', function() { ?> HTML in here. <?php } );
March 10, 2020 at 8:45 pm #13879Bodie J
ParticipantOh, 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?March 10, 2020 at 9:09 pm #13881Bodie J
ParticipantNevermind, 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 } );
March 12, 2020 at 8:01 pm #13924Tom
KeymasterGlad I could help! 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.