It's not that I'm so smart, it's just that I stay with problems longer.

Showing posts with label Solutions. Show all posts
Showing posts with label Solutions. Show all posts

Saturday, 15 June 2013

  • How to List most recent comments


    There’s plugins and widgets that allows you to list recent comments on your WordPress blog. But you know it, I like to avoid using many plugins and enjoy understand how things works. Here’s a nice code to display recent comments on your blog.

    <?php
      global $wpdb;
      $sql = "SELECT DISTINCT ID, post_title, post_password, comment_ID, comment_post_ID, comment_author, comment_date_gmt, comment_approved, comment_type,comment_author_url, SUBSTRING(comment_content,1,30) AS com_excerpt FROM $wpdb->comments LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID = $wpdb->posts.ID) WHERE comment_approved = '1' AND comment_type = '' AND post_password = '' ORDER BY comment_date_gmt DESC LIMIT 10";
    
      $comments = $wpdb->get_results($sql);
      $output = $pre_HTML;
      $output .= "\n<ul>";
      foreach ($comments as $comment) {
        $output .= "\n<li>".strip_tags($comment->comment_author) .":" . "<a href=\"" . get_permalink($comment->ID)."#comment-" . $comment->comment_ID . "\" title=\"on ".$comment->post_title . "\">" . strip_tags($comment->com_excerpt)."</a></li>";
      }
      $output .= "\n</ul>";
      $output .= $post_HTML;
      echo $output;
    ?>

  • Tuesday, 4 June 2013

  • How to Showing Related Posts Without A Plugin


    Showing related posts will increase the number of pageviews. You can show related posts with thumbnails either without thumbnails easily by a few lines of PHP.

    This code will display related posts based on the current post tag(s). It must be pasted within the loop.

    <?php
    //for use in the loop, list 5 post titles related to first tag on current post
    $tags = wp_get_post_tags($post->ID);
    if ($tags) {
      echo 'Related Posts';
      $first_tag = $tags[0]->term_id;
      $args=array(
        'tag__in' => array($first_tag),
        'post__not_in' => array($post->ID),
        'showposts'=>5,
        'caller_get_posts'=>1
       );
      $my_query = new WP_Query($args);
      if( $my_query->have_posts() ) {
        while ($my_query->have_posts()) : $my_query->the_post(); ?>
          <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
          <?php
        endwhile;
      }
    }
    ?>

  • How to - Showing Popular Posts Without A Plugin



    Just paste the following code on your sidebar.php file. To change the number of displayed posts, simply change the 5 on line 3.

    <h2>Popular Posts</h2>
    <ul>
    <?php $result = $wpdb->get_results("SELECT comment_count,ID,post_title FROM $wpdb->posts ORDER BY comment_count DESC LIMIT 0 , 5"); 
    foreach ($result as $post) { 
    setup_postdata($post);
    $postid = $post->ID; 
    $title = $post->post_title; 
    $commentcount = $post->comment_count; 
    if ($commentcount != 0) { ?> 
    <li><a href="<?php echo get_permalink($postid); ?>" title="<?php echo $title ?>">
    <?php echo $title ?></a> {<?php echo $commentcount ?>}</li>
    <?php } } ?>
    </ul>

  • Friday, 31 May 2013

  • WordPress Security Attacks, The Details and Solutions

    The Attack

    The details of the attack has been covered far and wide. Hostgator was one of the first big names to break the news about the attack with their Global WordPress Brute Force Flood post. The WordPress security team at Sucuri has as series of blog posts about the topic covering how to protect your site, the reality of the attacks, and the consequences of such attacks. Security blog Krebs on Security has a good post covering the topic in depth.
    The short and simple explanation of what is happening is that one or more illegal botnets (a network of hundreds, thousands, or millions of compromised computers that are being exploited to perform attacks, send spam, etc) are being used to brute-force attack WordPress sites. The goal of a brute force attack is to try as many username and password combinations as possible in order to find valid login credentials. It’s as if someone was trying to guess the combination on a combination lock, but rather than being limited to a single guess every few seconds, they could make hundreds or thousands of guesses a second while never getting tired.

    The Solution

    Brute force login attempts are by no means new. Such attack techniques have been used against WordPress sites for as long as WordPress has existed. In the past, I’ve recommended users install and activate the Login Lockdown plugin as it helps protect against brute force attacks. It protects the site by blocking login attempts by a specific IP once that IP has failed too many times in a row. Unfortunately, as the pattern section above shows, these attacks are coming from a huge range of IP addresses. Simply being able to block specific IP addresses after failed attempts will not protect a site against this botnet attack. This means that a different solution is needed.

  • Copyright @ 2013 Wordpress Joomla Fans.