Tagged: x
-
AuthorPosts
-
January 14, 2017 at 7:32 pm #1330346
rekluseParticipantHello, I was hoping someone might help me think through this. I am trying to create a shortcode that basically allows me to easily place the following on my page:
[wcm_nonmember] [content_band style="color: #333;" bg_color="#f7f7f7" border="all" inner_container="true"] [custom_headline style="margin-top: 0;" level="h4" looks_like="h4"]This video presentation was produced especially for Integral Life members.[/custom_headline] If you are a member, please log in. If not, we’d love to give you your <a href="/join">free trial membership</a> right now. [/content_band] [/wcm_nonmember]It might be a bit tricky, I realize, because it would be nesting many other shortcodes. But this would by far be the easiest approach, so if I ever need to change how this is displayed I can change it in one place and let it propagate across all my other pages, as opposed to having to change it in hundreds of individual pages, one at a time.
Any advice?
Thank you, as always!
January 15, 2017 at 1:50 am #1330565
ChristopherModeratorHi there,
Because this requires a template change, I’d advise that you setup a child theme. This allows you to make code changes that won’t be overwritten when an X update is released. After your child theme is setup, please review how we recommend making template changes in Customization Best Practices.
Please add following code in child theme’s functions.php file :
add_filter( 'the_content', 'add_custom_text' ); function add_custom_text($content){ if ( is_singular('page') ) { $content .= do_shortcode('[wcm_nonmember] [content_band style="color: #333;" bg_color="#f7f7f7" border="all" inner_container="true"] [custom_headline style="margin-top: 0;" level="h4" looks_like="h4"]This video presentation was produced especially for Integral Life members.[/custom_headline] If you are a member, please log in. If not, we’d love to give you your <a href="/join">free trial membership</a> right now. [/content_band] [/wcm_nonmember]'); } return $content; }Hope it helps.
January 15, 2017 at 6:45 pm #1331260
rekluseParticipantUnfortunately this didn’t seem to work =\
I was able to get this to work, however, with the exception of adding the [wcm_nonmember] [/wcm_nonmember] shortcodes. Can you help me modify this so it works?
function login_p_shortcode() { $output = '<div id="x-content-band-1" class="x-content-band border-top border-left border-right border-bottom" style="background-color: rgb(51, 51, 51); color: #eee; font-family:lato;"><div class="x-container max width"> <h5 class="h-custom-headline h5" style="margin-top: 0; color: #eee"><span>This Integral Life Practice module was lovingly produced for Integral Life members.</span></h5><p>If you are a member, please log in to experience the full practice. If not, we’d love to give you a <strong>free trial membership</strong> right now.</p><a class="x-btn x-btn-square x-btn-block" href="/join" >START YOUR INTEGRAL LIFE</a></div></div>'; return $output; } add_shortcode('login-p', 'login_p_shortcode');January 15, 2017 at 6:48 pm #1331327
rekluseParticipantNevermind, was able to figure it out. For anyone looking for a similar solution, you can use something like this:
function login_test_shortcode() { $output .= do_shortcode('[wcm_nonmember]<div id="x-content-band-1" class="x-content-band border-top border-left border-right border-bottom" style="background-color: #333; color: #eee; font-family:lato;"><div class="x-container max width"> <h5 class="h-custom-headline h5" style="margin-top: 0; color: #eee"><span>This video presentation was lovingly produced for Integral Life members.</span></h5><p>If you are a member, please log in to watch. If not, we’d love to give you a <strong>free trial membership</strong> right now.</p><a class="x-btn x-btn-square x-btn-block" href="/join" >START YOUR INTEGRAL LIFE</a></div></div>[/wcm_nonmember]'); return $output; } add_shortcode('login-test', 'login_test_shortcode');January 15, 2017 at 8:25 pm #1331375
NicoModeratorHappy to hear that.
Feel free to ask us again.
Thank you so much for sharing the answer.
-
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-1330346 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
