Carousel with Wordpress posts

Asked

Viewed 390 times

0

Hi, I’m trying to apply OWL-CAROUSEL to a custom post page. When I do in normal HTML, without PHP tags, it works great, but if I play in the wp_query loop it does not take the plugin and list the posts one under the other.

See the code below:

<div id="owl-demo" class="owl-carousel">

        <?php
            $estrutura = new WP_Query('post_type=estrutura&orderby=post_status&order=DESC&showposts=-1');
            if($estrutura->have_posts()):while($estrutura->have_posts()): $estrutura->the_post();
        ?>

            <div class="item">
                <span>
                    <?php echo get_the_post_thumbnail($page->ID, array(501,301)); ?>
                    <!-- TAMANHO DA IMAGEM DEVE SER 1024x615 -->

                    <h1><?php the_title(); ?></h1>
                </span>

                <div>
                    <?php the_content(); ?>
                </div>
            </div>

        <?php
            endwhile;
            endif;
            wp_reset_postdata();
        ?>

        </div>

How can I solve this problem? Remembering that scripts are ok, all being called, as well as css’s.

Thanks in advance.

  • Are you using some wordpress plugin to call the Owl-Carousel or are using the direct jquery plugin?

  • Hello Ricardo, I’m using the direct jquery plugin.

  • And you are doing the jquery plugin framework?

  • Yes, I use another plugin for navigation between tabs and works perfectly, in addition to other scripts. I took it to make sure it wasn’t a conflict between them, but it’s not.

  • As you commented that it works when the data is entered manually I believe that the problem is your Query. You can provide the generated HTML for this block?

1 answer

1


The problem lies in that line

<?php echo get_the_post_thumbnail($page->ID, array(501,301)); ?>

The correct one would be to use the $post variable which is the global variable for the post.

<?php echo get_the_post_thumbnail($post->ID, array(501,301)); ?>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.