• Resolved jonhs

    (@jonhs)


    My code starts like this in extras.php file:

    // start code

    function square_boxes_shortcode( $atts, $content = null ) {

    $ret = “<p>TEST</p>

    SHARE BUTTON HERE!

    <div class=’square-boxes’><div class=’square-boxes-wrapper’>”;

    // end code

    How do I insert share buttons shortcode where it says “SHARE BUTTONs HERE!”. I need to use this shortcode: [addtoany buttons=”facebook,twitter”]

    Thanks,
    Jon

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author micropat

    (@micropat)

    Use the AddToAny template tag in PHP like:

    $ret = '<p>TEST</p>';
    
    if ( function_exists( 'ADDTOANY_SHARE_SAVE_KIT' ) ) { 
        $ret .= ADDTOANY_SHARE_SAVE_KIT( array( 
            'buttons' => array( 'facebook', 'twitter' ),
            'output_later' => true,
        ) );
    }
    
    $ret .= '<div class="square-boxes"><div class="square-boxes-wrapper">';
    Thread Starter jonhs

    (@jonhs)

    Thank you. Can you advice how to insert shortcode in the below code. See placement where it says “SHORTCODE HERE” here:

    function square_boxes_shortcode( $atts, $content = null ) {
    
      $ret = "<p>Text</p>
      <p>Text</p>
    <p><strong>Text</strong><br />
    <div class='btn-varaa'><a href='https://xxx'>Text</a></div>
    <br />
    text</p>
    
      <p><a href='https://xxx'>Text/a></p>
    
    INSERT SHORTCODE HERE
    
    <div class='square-boxes'><div class='square-boxes-wrapper'>";
    
      $k=0;
      while(the_repeater_field('square_boxes', 'options')) {
        $k++;
        $text = get_sub_field('text');
        $lines = 1;
        $lines += substr_count($text, "<br/>");
        $lines += substr_count($text, "<br />");
        $lines += substr_count($text, "<br >");
        $lines += substr_count($text, "<br>");
    
        $ret .= "<div class='square-box box-nth-".($k%3)."'><a href='".get_sub_field('link')."'><span class='text lines-count-".$lines."'>".$text."</span></a></div>";
      }
    
      $ret .= "<div class='clearer'></div></div></div>";
    
      return $ret;
    }
    • This reply was modified 7 years, 1 month ago by jonhs.
    • This reply was modified 7 years, 1 month ago by jonhs.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Shortcode insertion to extras.php help needed’ is closed to new replies.