• Resolved learningwpatm

    (@learningwpatm)


    Greetings!

    I am trying to insert the slider into a div within my functions.php file. I can insert an image in the same spot and it works perfectly, but when i insert the meteor slideshow code instead i get: Parse error: syntax error, unexpected T_STRING, expecting ‘,’ or ‘;’ in /wp-content/themes/canvas/functions.php

    add_action( 'woo_content_before', 'woo_add_banner_notice' );
    
    function woo_add_banner_notice () {
    
      // Echo an alert box
      echo '
    <div class="banner_container">
    
    	<div class="banner_container_wrapper">
    		<div class="banner_box">
    			<div class="banner_box_image">
    				<?php if ( function_exists( 'meteor_slideshow' ) ) { meteor_slideshow(); } ?>
    			</div>
    		</div>
    	</div>
    </div>
    
    ';
    
    } // End woo_add_banner_notice()

    https://ww.wp.xz.cn/plugins/meteor-slides/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Josh Leuze

    (@jleuze)

    This is because the slideshow function you added already has closing and opening PHP tags and you added it within PHP, so the your PHP is closing early.

    Also, this function doesn’t need to be echoed, the function will already echo the slideshow. I wouldn’t really recommend doing multi-line echoes like that, it leaves more room for error and makes it harder to tell what is PHP and what is HTML.

    If you added it all as PHP, with no open or close tags for this section, it should work:

    function woo_add_banner_notice () {
    	// Echo an alert box
    	echo '<div class="banner_container">';
    		echo '<div class="banner_container_wrapper">';
    			echo '<div class="banner_box">';
    				echo '<div class="banner_box_image">';
    					if ( function_exists( 'meteor_slideshow' ) ) { meteor_slideshow(); }
    				echo '</div>';
    			echo '</div>';
    		echo '</div>';
    	echo '</div>';
    } // End woo_add_banner_notice()
    add_action( 'woo_content_before', 'woo_add_banner_notice' );
    Thread Starter learningwpatm

    (@learningwpatm)

    Thanks a lot Josh!

    If it isn’t too much trouble i have another question.

    Is it possible to show this slideshow only on the front page and target a specific slideshow for example: “slideshow_2”?

    Plugin Author Josh Leuze

    (@jleuze)

    No problem! You can do this with conditional tags, is_front_page will check to make sure it is the front page. And for multiple slideshows with Meteor Slides, you can specify one in the function parameters.

    The end result should look like this:

    function woo_add_banner_notice () {
    	// Echo an alert box
    	if ( is_front_page() ) {
    		echo '<div class="banner_container">';
    			echo '<div class="banner_container_wrapper">';
    				echo '<div class="banner_box">';
    					echo '<div class="banner_box_image">';
    						if ( function_exists( 'meteor_slideshow' ) ) { meteor_slideshow( "slideshow_2", "" ); }
    					echo '</div>';
    				echo '</div>';
    			echo '</div>';
    		echo '</div>';
    	}
    } // End woo_add_banner_notice()
    add_action( 'woo_content_before', 'woo_add_banner_notice' );
Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Adding php code problem’ is closed to new replies.