Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #1111187

    Hey everyone I created a custom shortcode and placed it into enfold’s child function.php. When ever i paste into a page that has the advanced builder enabled, the information gets displayed literally above everything and not in the area where i want it to be in. I submitted the link at the bottom of the problem.

    here is the code

    function prodsc() {
    
    $args = array('category' => array('Cascade Series', 'Color Turf Products', 'absolute-series', 'diamond-series', 'everglade-series', 'everlast-turf', 'imperial-series', 'marquee-series', 'natures-best-series', 'nylon-putt-series', 'putting-greens', 'tigerturf', 'platinum'), 'exclude' => array('19967', '20015'), 'limit' => 200, 'order' => 'ASC', 'orderby' => 'name',);
            $products = wc_get_products( $args );
     echo '<ul>';
            $input_id = 1;
            foreach( $products as $product ) {
     
                //skipping index that are multiples of 10 (multiples of 10 create problems as the input IDs)
                if ( $input_id % 10 == 0 ) {
                    $input_id++;
                }
    			$prodid = $product->get_short_description();
    			$prodname = $product->get_name();
    			
                echo '<li>' . $prodname . ' <a href="'.$prodid.'" target="_blank">Download Spec Sheet</a></li>';
     
                $input_id++;
    			
            }
     echo '</ul>';
    	return true;
     
        }
    add_shortcode('prodsc','prodsc');

    any advice is welcomed. this works perfectly in the default editor but of course i need this to work in the avia advanced layout builder

    #1111188

    fixed it! for anyone that is curious to see the solution…you can’t use echo you need to use $html .= and return $html;

    function prodsc() {
    
    $args = array('category' => array('Cascade Series', 'Color Turf Products', 'absolute-series', 'diamond-series', 'everglade-series', 'everlast-turf', 'imperial-series', 'marquee-series', 'natures-best-series', 'nylon-putt-series', 'putting-greens', 'tigerturf', 'platinum'), 'exclude' => array('19967', '20015'), 'limit' => 200, 'order' => 'ASC', 'orderby' => 'name',);
            $products = wc_get_products( $args );
     $html .=  '<ul>';
            $input_id = 1;
            foreach( $products as $product ) {
     
                //skipping index that are multiples of 10 (multiples of 10 create problems as the input IDs)
                if ( $input_id % 10 == 0 ) {
                    $input_id++;
                }
    			$prodid = $product->get_short_description();
    			$prodname = $product->get_name();
    			
                 $html .=  '<li>' . $prodname . ' <a href="'.$prodid.'" target="_blank">Download Spec Sheet</a></li>';
     
                $input_id++;
    			
            }
     $html .=  '</ul>';
    	return $html;
     
        }
    add_shortcode('prodsc','prodsc');
    #1111450

    Hi,

    Thank you very much for sharing, we appreciate it a lot.

    Best regards,
    Basilis

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