How do I change the wordpress loop category via ajax

Asked

Viewed 47 times

1

I will have a select with 3 categories, every time I change the value of select it changes the result of lop Example:

<select>
  <option value="Noticias">Noticias</option>
  <option value="Shopping">Saab</option>
  <option value="Musica">Musica</option>
</select>


<section class="container">
        <div class="list_article" role="carousel">
            <?php $args = array(
                    'post_type'=>'novidades',
                    'numberposts'=> 3
                );
                $counter = 0;
                $my_posts = get_posts($args);
                if( $my_posts ): foreach( $my_posts as $post ) :   setup_postdata($post); ; $counter++ ?>
                    <article class="_card">
                        <a href="<?php the_permalink() ?>">
                         <h3><?php the_title() ?></h3>
                        </a>
                    </article>
                <?php
                wp_reset_query();
                endforeach; else: ?>
                    <p>Nada encontrado.</p>
            <?php endif; ?>
        </div>
        <hr>
    </section><!-- end container -->
  • What have you tried? jQuery.load can help you http://api.jquery.com/load/ if your case is quite simple. If you need help with Ajax in Wordpress I made a detailed explanation here: http://answall.com/a/160069/5213

No answers

Browser other questions tagged

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