WordPress.org

Ready to get started?Download WordPress

Forums

Plugin works on my blog but not on other WP installs (1 post)

  1. robertbrokeplugin
    Member
    Posted 7 years ago #

    I wrote this plugin for my blog to show posts that hadn't been commented on, yet it doesn't seem to work else where...

    Can anyone give me any pointers as to where it might be going wrong, or at least some advice on writing it in a way that would be WP network compatable?

    Any advice would be much appreciated.
    <?php
    function show_tumbleweed() {
    global $wpdb, $siteurl, $tableposts;
    //get total posts
    @$tpostsq = "select ID from $tableposts where post_type ='post' and DATE_SUB(CURDATE(),INTERVAL 90 DAY) <= post_date";
    $tpostsres = mysql_query($tpostsq);
    @$tpostsnum=mysql_num_rows($tpostsres);

    //get count for posts with > 2 comments
    @$ctpostsq = "select ID from $tableposts where comment_count > '2' and post_type ='post' and DATE_SUB(CURDATE(),INTERVAL 90 DAY) <= post_date";
    @ $ctpostsres = mysql_query($ctpostsq);
    @$ctpostsnum=mysql_num_rows($ctpostsres);
    $nocomment=$tpostsnum - $ctpostsnum;
    @$trraw=round((($nocomment/$tpostsnum)*100), 2);
    @$tr=round((($nocomment/$tpostsnum)*100));
    if(($tr > '0') AND ($tr <= '9')){
    $tr=10;
    }
    if(($tr > '9') AND ($tr <= '16')){
    $tr=9;
    }
    if(($tr > '16') AND ($tr <= '24')){
    $tr=8;
    }
    if(($tr > '24') AND ($tr <= '36')){
    $tr=7;
    }
    if(($tr > '36') AND ($tr <= '46')){
    $tr=6;
    }
    if(($tr > '46') AND ($tr <= '56')){
    $tr=5;
    }
    if(($tr > '56') AND ($tr <= '66')){
    $tr=4;
    }
    if(($tr > '66') AND ($tr <= '76')){
    $tr=3;
    }
    if(($tr > '76') AND ($tr <= '89')){
    $tr=2;
    }
    if(($tr > '89') AND ($tr <= '100')){
    $tr=1;
    }

    echo"<div><img src=\"$siteurl/tumbleimagesdir/tumble-$tr.jpg\" border=0 title=\"This blog is a TR$tr or $trraw% of current posts made during the last 90 days received less than 3 comments\" alt=\"A TR$tr blog\" align=center><br>";

    $query = "select guid, post_title, comment_count, post_type from $tableposts where comment_count = '0' and post_type ='post' and DATE_SUB(CURDATE(),INTERVAL 90 DAY) <= post_date ORDER BY rand() asc LIMIT 5";
    @ $result = mysql_query($query);
    @$advnum_results=mysql_num_rows($result);

    echo"<b>5 you may have missed...</b><br>";
    for ($i=0; $i <$advnum_results; $i++) {
    @ $row = mysql_fetch_array($result);

    echo "

  2. $row[post_title]
  3. ";

    }
    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags