How to insert font-awesome icon in a shortcode inside script?

I have inserted a shortcode in functions.php file. The shorcode is :

function multi_carousel_random_shortcode($atts){ extract( shortcode_atts( array( ‘post_type’ => ‘carousel-item’, ), $atts ) );

$q = new WP_Query(
    array('posts_per_page' => -1, 'post_type' => $post_type)     
    );      
$list = '

<script>
jQuery(document).ready(function() {
  jQuery("#owl-demo-eleven").owlCarousel({
        navigation: true,
        navigationText: ["<i class=fa fa-angle-left></i>","<i class='fa fa-angle-right'></i>"],
      });
    });
</script>       
<div id="owl-demo-eleven" class="owl-carousel owl-theme">
';
while($q->have_posts()) : $q->the_post();
    $idd = get_the_ID();
    $carousel_img = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID), 'carousel-small' );

    $list .= '
    <div class="item"><img src="'.$carousel_img[0].'" alt="" /></div>   
';        
endwhile;
$list.= '
</div>
';
wp_reset_query();
return $list;

}
add_shortcode(‘multi_carousel_random’, ‘multi_carousel_random_shortcode’);

This question already has an answer here:

PHP Parse/Syntax Errors; and How to solve them? 10 answers

I have inserted a shortcode in functions.php file. The shorcode is :

function multi_carousel_random_shortcode($atts){ extract( shortcode_atts( array( ‘post_type’ => ‘carousel-item’, ), $atts ) );

$q = new WP_Query(
    array('posts_per_page' => -1, 'post_type' => $post_type)     
    );      
$list = '

<script>
jQuery(document).ready(function() {
  jQuery("#owl-demo-eleven").owlCarousel({
        navigation: true,
        navigationText: ["<i class=fa fa-angle-left></i>","<i class='fa fa-angle-right'></i>"],
      });
    });
</script>       
<div id="owl-demo-eleven" class="owl-carousel owl-theme">
';
while($q->have_posts()) : $q->the_post();
    $idd = get_the_ID();
    $carousel_img = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID), 'carousel-small' );

    $list .= '
    <div class="item"><img src="'.$carousel_img[0].'" alt="" /></div>   
';        
endwhile;
$list.= '
</div>
';
wp_reset_query();
return $list;

}
add_shortcode(‘multi_carousel_random’, ‘multi_carousel_random_shortcode’);

‘icon code’ in navigationText is producing error. How to insert font-awesome icon inside script?


Source: wordpress

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.