• Vladislav306907

    (@vladislav306907)


    I apologize in advance for my english.

    Good day, I describe the following issue and I hope that I will find help in solving the problem.
    I have a list of the categories: when you click on a category, I Ickes must be loaded last 3 entries in this category.
    As I will implement:
    1) displays a list of categories

    <?php
    			$args = array(
    				'orderby'            => 'ID',
    				'order'              => 'ASC',
    				'style'              => 'list',
    				'show_count'         => 0,
    				'hide_empty'         => 0,
    				'use_desc_for_title' => 0,
    				'child_of'           => 3,
    				'feed'               => '',
    				'feed_type'          => '',
    				'feed_image'         => '',
    				'exclude'            => '',
    				'exclude_tree'       => '',
    				'include'            => '',
    				'hierarchical'       => false,
    				'title_li'           => '',
    				'number'             => NULL,
    				'echo'               => 1,
    				'depth'              => -1,
    				'current_category'   => 'active-cat',
    				'pad_counts'         => 0,
    				'taxonomy'           => 'category',
    				'walker'             => 'Walker_Category',
    				'hide_title_if_empty' => true,
    			);
    				wp_list_categories( $args );
    			?>

    2) Next, we derive the categories records

    
    <?php query_posts(‘category_name=echo $_POST[“link”];’); ?> //
    

    HERE in the variable LINK WITH US IS SUBJECT Category Name by clicking on the HER Samui, IE gets that click-through we have going on AJAX querying and updating the list of records

    
    <?php while (have_posts()) : the_post(); ?>
    <?php $cat = get_the_category($post->ID); ?>
    <div class=”col-lg-4 <?php echo $cat[0]->category_nicename; ?>”>
    <div class=”case_block”>
    <div class=”case_hover”>“></div>
    <p><?php the_title(); ?></p>
    /images/case_lab.png” alt=”case”>
    </div>
    </div>
    <?php endwhile; ?>
    

    3) Now sovstvenno himself violin, which pulls out the name of the category and its vstavlet variable link

    
    jQuery('.case ul li a').click(function(e){
    e.preventDefault();
    var hash = atr.split('case-studies/')[1];
    var link = hash.split('/')[0];
    jQuery.ajax({
    url: "index.php",
    type: "POST",
    data: "link="+link,
    success: function(responseText){
    alert(responseText);
    }
    });
    });
    
  • The topic ‘ajax update categories’ is closed to new replies.