WordPress.org

Ready to get started?Download WordPress

Forums

How to input query code in this index page? (6 posts)

  1. BLuu123
    Member
    Posted 2 years ago #

    Hi,
    Im using "VoteItUp" plugin (it allows users to vote posts up or down), and id like for posts to be displayed according to those votes.

    What I think I need to do is add something like this

    <?php global $query_string;
    query_posts( $query_string . '&order=<?php MostVotedAllTime(); ?>
      <?php endif; ?>

    somewhere in the file.

    Here is my full index code

    <?php get_header(); ?>
    
    		 <!-- Begin Content -->
    
    		 <div id="content">
    
    	<?php if (have_posts()) : ?>
    
    		<?php while (have_posts()) : the_post(); ?>
    
    		       <div <?php post_class() ?> id="post-<?php the_ID(); ?>">
    
    			   <div class="p-heading"><h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2></div>
    
    			   <div class="p-content">
    
    			   <?php the_content('Read the rest of this entry »'); ?>
    
    			   </div>
    
    			   <div class="p-info"><?php the_time('F jS, Y') ?> | <?php the_category(', '); ?> | <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></div>
    
    			   </div>
    
    <?php endwhile; ?>
    
    <div class="navigation">
    
    <div class="alignleft"><?php next_posts_link('« Older Entries') ?></div>
    
    			<div class="alignright"><?php previous_posts_link('Newer Entries »') ?></div>
    
    <div class="clear"></div>
    
    </div>
    
    	<?php else : ?>
    
    <div class="post">
    
    		<div class="p-heading"><h2 class="center">Not Found</h2></div>
    
    		<div class="p-content"><p class="center">Sorry, but you are looking for something that isn't here.</p>
    
    		<?php get_search_form(); ?></div>
    
    </div>
    
    	<?php endif; ?>
    
    		 </div>
    
    		 <!-- End Content -->
    
    <?php get_sidebar(); ?>
    
    <?php get_footer(); ?>

    could someone please help me

  2. Shail
    Member
    Posted 2 years ago #

    Backup your file and replace with this code may it work for you..

    <?php get_header(); ?>
    
    		 <!-- Begin Content -->
    
    		 <div id="content">
    <?php global $query_string;
    query_posts( $query_string . '&order=<?php MostVotedAllTime(); ?>
    	<?php if (have_posts()) : ?>
    
    		<?php while (have_posts()) : the_post(); ?>
    
    		       <div <?php post_class() ?> id="post-<?php the_ID(); ?>">
    
    			   <div class="p-heading"><h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2></div>
    
    			   <div class="p-content">
    
    			   <?php the_content('Read the rest of this entry »'); ?>
    
    			   </div>
    
    			   <div class="p-info"><?php the_time('F jS, Y') ?> | <?php the_category(', '); ?> | <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></div>
    
    			   </div>
    
    <?php endwhile; ?>
    
    <div class="navigation">
    
    <div class="alignleft"><?php next_posts_link('« Older Entries') ?></div>
    
    			<div class="alignright"><?php previous_posts_link('Newer Entries »') ?></div>
    
    <div class="clear"></div>
    
    </div>
    
    	<?php else : ?>
    
    <div class="post">
    
    		<div class="p-heading"><h2 class="center">Not Found</h2></div>
    
    		<div class="p-content"><p class="center">Sorry, but you are looking for something that isn't here.</p>
    
    		<?php get_search_form(); ?></div>
    
    </div>
    
    	<?php endif; ?>
    
    		 </div>
    
    		 <!-- End Content -->
    
    <?php get_sidebar(); ?>
    
    <?php get_footer(); ?>
  3. BLuu123
    Member
    Posted 2 years ago #

    Thanks for the reply.

    Now it says:
    Parse error: syntax error, unexpected T_STRING in /home/mrbelu/public_html/gamingtops.com/wp-content/themes/bluish/index.php on line 18

  4. Shail
    Member
    Posted 2 years ago #

    I think this is very easy fix i have do it....

    <?php get_header(); ?>
    
    		 <!-- Begin Content -->
    
    		 <div id="content">
    <?php global $query_string;
    query_posts( $query_string . '&order='.MostVotedAllTime(); ?>
    	<?php if (have_posts()) : ?>
    
    		<?php while (have_posts()) : the_post(); ?>
    
    		       <div <?php post_class() ?> id="post-<?php the_ID(); ?>">
    
    			   <div class="p-heading"><h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2></div>
    
    			   <div class="p-content">
    
    			   <?php the_content('Read the rest of this entry »'); ?>
    
    			   </div>
    
    			   <div class="p-info"><?php the_time('F jS, Y') ?> | <?php the_category(', '); ?> | <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></div>
    
    			   </div>
    
    <?php endwhile; ?>
    
    <div class="navigation">
    
    <div class="alignleft"><?php next_posts_link('« Older Entries') ?></div>
    
    			<div class="alignright"><?php previous_posts_link('Newer Entries »') ?></div>
    
    <div class="clear"></div>
    
    </div>
    
    	<?php else : ?>
    
    <div class="post">
    
    		<div class="p-heading"><h2 class="center">Not Found</h2></div>
    
    		<div class="p-content"><p class="center">Sorry, but you are looking for something that isn't here.</p>
    
    		<?php get_search_form(); ?></div>
    
    </div>
    
    	<?php endif; ?>
    
    		 </div>
    
    		 <!-- End Content -->
    
    <?php get_sidebar(); ?>
    
    <?php get_footer(); ?>
  5. BLuu123
    Member
    Posted 1 year ago #

    after i paste that one -
    Parse error: syntax error, unexpected ';' in index.php on line 7

  6. Shail
    Member
    Posted 1 year ago #

    Your line seven current code is

    query_posts( $query_string . '&order='.MostVotedAllTime(); ?>

    Replace it with below line

    query_posts( $query_string . '&order='.MostVotedAllTime()); ?>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.