Need PHP Help - WordPress (Simple Task)

Discussion in 'PHP' started by Amit1980, Jun 1, 2010.

  1. #1
    Hello,

    My WordPress blog's homepage has special system. It shows recent posts on homepage. But when 'WP-Ratings' plugin is enabled it replaces Recent Posts with Popular posts and shows top rated articles.

    Now I want to turn off this feature. I want to show recent articles always and popular articles when plugin is enabled. It should replace recent post plugin.

    Here is the code - Please take a look -

        <div id="content">
          <h1><?php if (function_exists('get_highest_rated')) { echo 'Popular Articles'; } else { echo 'Recent Articles'; } ?></h1>
            <div class="post_wrap home">
            <?php 
    		if (function_exists('get_highest_rated')) { 
    			get_highest_rated('post', 0, 5);
    		} else if (have_posts()) { while (have_posts()) { the_post(); ?>
            <div <?php if ( function_exists('post_class') ) { echo post_class(); } else { echo 'class="post"'; } ?> id="post-<?php the_ID(); ?>">
            <div <?php if ($counter == 1) {
    		  echo 'class="first"';
    		  } elseif ($counter == 2) {
    		  echo 'class="second"'; } ?>>
              <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
                <?php the_title(); ?>
                </a></h2>
              <?php the_excerpt(); ?>
              <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">Read Article ›</a>
              </div>
            </div>
            <?php $counter++; ?>
            <?php } ?>
            
            <?php } else { ?>
            <h2 class="center">Not Found</h2>
            <p class="center">Sorry, but you are looking for something that isn't here.</p>
            <?php } ?>
          </div>
    PHP:
    If you are WordPress theme developer contact me. I need one WP Developer. Thank you!
     
    Amit1980, Jun 1, 2010 IP
  2. roopajyothi

    roopajyothi Active Member

    Messages:
    1,302
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #2
    Better you can use a Loop or Switch case for that Problem! :)
     
    roopajyothi, Jun 1, 2010 IP
  3. Amit1980

    Amit1980 Guest

    Messages:
    97
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thank you :)
     
    Amit1980, Jun 2, 2010 IP
  4. roopajyothi

    roopajyothi Active Member

    Messages:
    1,302
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #4
    Hope it solves your problem?
    Right?
     
    roopajyothi, Jun 2, 2010 IP
  5. dabaR

    dabaR Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
        <div id="content">
          <h1><?php echo (function_exists('get_highest_rated') ? 'Most Popular & ' : '') . 'Recent Articles' ; ?></h1>
            <div class="post_wrap home">
            <?php 
    		if (function_exists('get_highest_rated')) { 
    			get_highest_rated('post', 0, 5);
    		} 
             ?>
             <?php if (have_posts()) { while (have_posts()) { the_post(); ?>
            <div <?php if ( function_exists('post_class') ) { echo post_class(); } else { echo 'class="post"'; } ?> id="post-<?php the_ID(); ?>">
            <div <?php if ($counter == 1) {
    		  echo 'class="first"';
    		  } elseif ($counter == 2) {
    		  echo 'class="second"'; } ?>>
              <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
                <?php the_title(); ?>
                </a></h2>
              <?php the_excerpt(); ?>
              <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">Read Article ›</a>
              </div>
            </div>
            <?php $counter++; ?>
            <?php } ?>
            
            <?php } else { ?>
            <h2 class="center">Not Found</h2>
            <p class="center">Sorry, but you are looking for something that isn't here.</p>
            <?php } ?>
          </div>
    PHP:
     
    dabaR, Jun 2, 2010 IP
  6. Amit1980

    Amit1980 Guest

    Messages:
    97
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Thank you :) Yes now its working perfectly. Rep+ added :)
     
    Amit1980, Jun 3, 2010 IP