Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1330346
    rekluse
    Participant

    Hello, 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!

    #1330565
    Christopher
    Moderator

    Hi 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.

    #1331260
    rekluse
    Participant

    Unfortunately 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');
    #1331327
    rekluse
    Participant

    Nevermind, 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');
    #1331375
    Nico
    Moderator

    Happy to hear that.

    Feel free to ask us again.

    Thank you so much for sharing the answer.

  • <script> jQuery(function($){ $("#no-reply-1330346 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>