0

Today I try to integrate sequence slider and advance custom files plugin in WordPress.

There is a problem I faced. I create a field in advance custom files name "slider_type" . then I create 2 conditional filed. image_slider and video_slider.

Now I want to display it in my WordPress homepage/WordPress themes.

Means, when some one select slider type image from backend, font end work only image function or its display only image. or not its display video.

here is my code what I written:

<ul class="sequence-canvas">
            <?php
                query_posts('post_type=myslider');
                if (have_posts()) : while (have_posts()) : the_post();
            ?>
            <li class="<?php the_field('li_class'); ?>">
                <div class="<?php the_field('layout_of_slider'); ?>">
                    <h2><?php the_title(); ?></h2>
                    <p><?php the_content(); ?></p>
                </div>

                <?php if(get_field('slider_type') == "Image") {

                <img src=\"<?php (get_field('slider_image'); ?>\">

                }
                else {

                <p><?php (get_field('slider_video'); ?></p>

                }
            ?>

            <?php endwhile; endif;  wp_reset_query();   ?>
        </li>
        </ul>

When I run this code, my WordPress themes show blank. What is fault here?

1

1 Answer 1

1

That is not valid PHP, try:

<?php if(get_field('slider_type') == "Image") : ?>

  <img src="<?php get_field('slider_image'); ?>">

<?php else: ?>

  <p><?php get_field('slider_video'); ?></p>

<?php endif ?>

instead of:

<?php if(get_field('slider_type') == "Image") {

    <img src=\"<?php (get_field('slider_image'); ?>\">

    }
    else {

    <p><?php (get_field('slider_video'); ?></p>

    }
?>
Sign up to request clarification or add additional context in comments.

3 Comments

Specifically, they will need to either echo all HTML code or close the PHP tags.
#Brandon, Still not work and show error :( I also try using echo "";
@NoDiv_NoClass I accidentally copied a syntax error over. Please try the code now (I've updated my answer)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.