Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #5834
    mylove007
    Participant

    i my previous post i asked
    about

    have one query
    i have making listing site

    url is

    http://restaurants.thebusinessrank.com/listingcategory/restaurants-in-agra/

    im using
    Tevolution-Directory

    i have to order this listing(post) max view to lowest view
    you say rank wise

    what is query to add and where in which file
    thanks in advance

    i tried custom WP_Query just add ‘orderby’ => ‘post_views’ to your query parameters.as you say
    but wont work
    below is the code can you please help me and add this code

    thanks

    <?php
    /**
     * Directory Category taxonomy page
     *
    **/
    get_header(); //Header Portion
    $tmpdata = get_option('templatic_settings');
    global $posts,$htmlvar_name;
    ?>
    <script type="text/javascript">
    var category_map = '<?php echo $tmpdata['category_map'];?>';
    <?php if($_COOKIE['display_view']=='event_map' && $tmpdata['category_map']=='yes'):?>
    jQuery(function() {			
    	jQuery('#listpagi').hide();
    });
    <?php endif;?>
    </script>
    <?php 
    do_action('after_directory_header');
    
     /*do action for display the breadcrumb in between header and container. */
     do_action('directory_before_container_breadcrumb'); ?>
    <div id="content" class="contentarea <?php directory_class();?>">
    	
    	<?php do_action('directory_inside_container_breadcrumb'); /*do action for display the breadcrumb  inside the container. */ ?>
         
        <div class="view_type_wrap">
         <?php
    	 /* Hooks for category title */
    	 do_action('directory_before_categories_title'); ?>
         
    	 <h1 class="loop-title"><?php single_cat_title(); ?></h1>
        
    	 <?php do_action('directory_after_categories_title'); 
         /* Hooks for category title end */
         
    	  /* Hooks for category description */
    	 do_action('directory_before_categories_description'); 
    
    	 if ( category_description() ) : /* Show an optional category description */ ?>
              <div class="archive-meta"><?php echo category_description(); ?></div>
         <?php endif; 
    
    	 do_action('directory_after_categories_description');
    	  /* Hooks for category description */
    	 ?>
         
         <?php do_action('directory_before_subcategory');
    	 
    		do_action('directory_subcategory');
    			/* Loads the sidebar-before-content. */
    			if(function_exists('supreme_sidebar_before_content'))
    		   apply_filters('tmpl_before-content',supreme_sidebar_before_content() ); 
    		   
    		do_action('directory_after_subcategory');
    	 ?>
        </div>
         <!--Start loop taxonomy page-->
       
       <?php do_action('directory_before_loop_taxonomy');?>
         <?php 
    
    /*
    add_filter('posts_orderby', 'views_posts_listing_custom' );
    
    function views_posts_listing_custom( $orderby )
    {
    global $wpdb,$wp_query,$post;
    $orderby="(SELECT SUM( count ) AS views
    FROM wp_i2b6c5t1_post_views, wp_i2b6c5t1_posts
    WHERE wp_i2b6c5t1_posts.ID = wp_i2b6c5t1_post_views.id
    AND TYPE =4
    GROUP BY wp_i2b6c5t1_post_views.id DESC");
     // $orderby=" (SELECT distinct $wpdb->postmeta.meta_value from $wpdb->postmeta where ($wpdb->posts.ID = $wpdb->postmeta.post_id) AND $wpdb-//>postmeta.meta_key = 'viewed_count' ) DESC";
      return $orderby;
    }
    */
    
    ?>
        <!--Start loop taxonomy page-->
        <div id="loop_listing_taxonomy" class="<?php if(isset($tmpdata['default_page_view']) && $tmpdata['default_page_view']=="gridview"){echo 'grid';}else{echo 'list';}?>" <?php if( is_plugin_active('Tevolution-Directory/directory.php') && isset($tmpdata['default_page_view']) && $tmpdata['default_page_view']=="mapview"){ echo 'style="display: none;"';}?>>
    
        <?php if (have_posts()) : 
    			while (have_posts()) : the_post(); ?>
    
    				<?php do_action('directory_before_post_loop');?>
    				 
    				<div class="post <?php templ_post_class();?>" >  
    					<?php 
    					/* Hook to display before image */	
    					do_action('directory_before_category_page_image');
    						
    					/* Hook to Display Listing Image  */
    					do_action('directory_category_page_image');
    					 
    					/* Hook to Display After Image  */						 
    					do_action('directory_after_category_page_image'); 
    					   
    					/* Before Entry Div  */	
    					do_action('directory_before_post_entry');?> 
    					
    					<!-- Entry Start -->
    					<div class="entry"> 
    					   
    						<?php  /* do action for before the post title.*/ 
    						do_action('directory_before_post_title');         ?>
    					   <div class="listing-wrapper">
    						<!-- Entry title start -->
    						<div class="entry-title">
    					   
    						<?php do_action('templ_post_title');                /* do action for display the single post title */?>
    					   
    						</div>
    						
    						<?php do_action('directory_after_post_title');          /* do action for after the post title.*/?>
    					   
    						<!-- Entry title end -->
    						
    						<!-- Entry details start -->
    						<div class="entry-details">
    						
    						<?php  /* Hook to get Entry details - Like address,phone number or any static field  */  
    						do_action('listing_post_info');   ?>     
    						
    						</div>
    						<!-- Entry details end -->
    					   </div>
    
    						<!--Start Post Content -->
    						<?php /* Hook for before post content . */ 
    					   
    						do_action('directory_before_post_content'); 
    						
    						/* Hook to display post content . */ 
    						do_action('templ_taxonomy_content');
    					   
    						/* Hook for after the post content. */
    						do_action('directory_after_post_content'); 
    						?>
    						<!-- End Post Content -->
    					   <?php 
    					    /* Hook for before listing categories     */
    						do_action('directory_before_taxonomies');
    					    
    						/* Display listing categories     */
    					    do_action('templ_the_taxonomies'); 
    
    						/* Hook to display the listing comments, add to favorite and pinpoint   */						
    						do_action('directory_after_taxonomies');?>
    					</div>
    					<!-- Entry End -->
    					<?php do_action('directory_after_post_entry');?>
    				</div>
    			<?php do_action('directory_after_post_loop');
              	endwhile;
    			wp_reset_query(); 
    		else:?>
              	<p class='nodata_msg'><?php _e( 'Apologies, but no results were found for the requested archive.', DIR_DOMAIN ); ?></p>              
            <?php endif; ?>
         </div>
        <?php do_action('directory_after_loop_taxonomy');
    	 
    	if(function_exists('supreme_sidebar_after_content'))
    		apply_filters('tmpl_after-content',supreme_sidebar_after_content());  /* after-content-sidebar - use remove filter to don't display it */
    	/* pagination start */
    	if($wp_query->max_num_pages !=1):?>
    	<div id="listpagi">
    		<div class="pagination pagination-position">
    			<?php if(function_exists('pagenavi_plugin')) { pagenavi_plugin(); } ?>
    		</div>
    	</div>
        <?php endif; /* pagination end */?>
          <!--End loop taxonomy page -->
    </div>
    <!--taxonomy  sidebar -->
    <?php 
    $taxonomy_name=$wp_query->queried_object->taxonomy;
    if ( is_active_sidebar( $taxonomy_name.'_listing_sidebar') ) : ?>
    	<div id="sidebar-primary" class="sidebar">
    		<?php dynamic_sidebar($taxonomy_name.'_listing_sidebar'); ?>
    	</div>
    <?php 
    elseif ( is_active_sidebar( 'primary-sidebar') ) : ?>
    	<div id="sidebar-primary" class="sidebar">
    		<?php dynamic_sidebar('primary-sidebar'); ?>
    	</div>
    <?php endif; ?>
    <!--end taxonomy sidebar -->
    <?php get_footer(); ?>
    #5843
    Bartosz
    Keymaster

    Oh man, I completely don’t know what this code does.

    Simple query like that fould give you the desired result:

    $args = array(
    	'posts_per_page' => 10,
    	'order' => 'desc',
    	'post_type' => 'post',
    	'suppress_filters' => false,
    	'orderby' => 'post_views'
    );
    get_posts($args);
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.