Closed Thread
Results 1 to 4 of 4

Thread: Help! Wordpress problem

  1. #1
    jasoncdu is offline Newbie
    Join Date
    Feb 2008
    Posts
    2
    Rep Power
    0

    Help! Wordpress problem

    Hey, everyone, before I being I would just like you all to know I'm pretty much a html / php noob.

    Now, first go here: bandeq(DOT)com/taiwan/

    The area where it says 'Popular this month', is currently not showing anything although it is supposed to show the posts with the most views. It was working fine before - untill I updated the plugin to post view PLUS. Now it just shows N/A as the output.


    Here is the code for the sidebar

    Code:
    <li>
    <h3 class="sidebartitle"><?php _e('Popular This Month'); ?></h3>
    <?php if(function_exists('get_most_viewed')): ?>
      <ul> <?php get_most_viewed(); ?></ul>
    <?php endif; ?> </li>

    </ul>
    </div>
    <?php endif; ?>
    </div>
    <!--/sidebar -->
    And here is the code for the function

    Code:
    // Function: Display Most Viewed Page/Post
    if( !function_exists('get_most_viewed') ) {
        function 
    get_most_viewed($mode=''$limit=10$chars=0$display=true$with_bot=true) {
            global 
    $wpdb$post;
            
    $output_format get_settings('PV+_option');
            if( 
    $mode=='post' ) {
                
    $where "p.post_type = 'post'";
            } elseif( 
    $mode=='page' ) {
                
    $where "p.post_type = 'page'";
            } else {
                
    $where "(p.post_type = 'post' OR p.post_type = 'page')";
            }
            if( 
    $with_bot ) {
                
    $most_viewed $wpdb->get_results("SELECT p.ID, p.post_title, p.post_name, p.post_status, p.post_date, (CAST(pm1.meta_value AS UNSIGNED) + CAST(pm2.meta_value AS UNSIGNED)) AS views FROM ".$wpdb->posts." AS p LEFT JOIN ".$wpdb->postmeta." AS pm1 ON pm1.post_id = p.ID LEFT JOIN ".$wpdb->postmeta." AS pm2 ON pm2.post_id = p.ID WHERE p.post_date < '".current_time('mysql')."' AND p.post_status = 'publish' AND ".$where." AND pm1.meta_key = 'views' AND pm2.meta_key = 'bot_views' AND p.post_password = '' ORDER BY views DESC LIMIT ".$limit);
                
    $output_format $output_format['mostviewsbot'];
            } else {
                
    $most_viewed $wpdb->get_results("SELECT p.ID, p.post_title, p.post_name, p.post_status, p.post_date, CAST(pm.meta_value AS UNSIGNED) AS views FROM ".$wpdb->posts." AS p LEFT JOIN ".$wpdb->postmeta." AS pm ON pm.post_id = p.ID WHERE p.post_date < '".current_time('mysql')."' AND p.post_status = 'publish' AND ".$where." AND pm.meta_key = 'views' AND p.post_password = '' ORDER BY views DESC LIMIT ".$limit);
                
    $output_format $output_format['mostviewsnobot'];
            }
            if( 
    $most_viewed ) {
                
    $output '';
                foreach(
    $most_viewed as $post) {
                    
    $post_title $post->post_title;
                    
    $post_views number_format(intval($post->views));
                    
    $link '<a href="'.get_permalink().'">'.snippet_chars($post_title$chars).'</a>';
                    
    $output .= '<li>'.sprintf($output_format,$post_views,$link).'</li>'."\n";
                }
            } else {
                
    $output '<li>'.__('N/A''wp-postviews_plus').'</li>';
            }
            if( 
    $display ) {
                echo 
    $output;
            } else {
                return 
    $output;
            }
        }

    Now my question is: what would I have to do / what code would I have to change / replace so that the output is actually shown?

    Hope that makes sense and sorry about the stretched screen ..

    Thanks in advanced,
    Jason

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    Jordan Guest
    So if( $most_viewed ) {
    is false then your else statement gets executed which prints $output = '<li>'.__('N/A', 'wp-postviews_plus').'</li>'; or "N/A", right? If so, that means your database code is incorrect and fetching no rows. Try adding

    Code:
    error_reporting(E_ALL); 
    to the top of your script and see if you receive any notices.

  4. #3
    jasoncdu is offline Newbie
    Join Date
    Feb 2008
    Posts
    2
    Rep Power
    0
    Hmm .. sorry Jordan, but your method didn't work. It just created alot and alot of php errors. The problem has changed now .. take a look Here It now displays the most viewed posts, but it doesn't show the title. Instead it just shows " ... " Can anyone tell me why this is happening? and possibily the solution.

    Thanks,
    Jason

  5. #4
    Jordan Guest
    What I told you to add was a method of turning errors on so you could see what errors occurred. You should leave that set while debugging and resolve all PHP errors that you see/get.

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 1
    Last Post: 11-02-2011, 06:46 PM
  2. Replies: 0
    Last Post: 07-26-2011, 10:55 AM
  3. WordPress site problem
    By RuneNova91 in forum JavaScript and CSS
    Replies: 2
    Last Post: 02-03-2011, 09:40 PM
  4. Wordpress... Problem with Description Page
    By groogruxking40 in forum HTML Programming
    Replies: 1
    Last Post: 09-23-2009, 07:01 PM
  5. Replies: 0
    Last Post: 08-15-2009, 12:58 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts