show related posts wordpress without plugin using category

How to show related posts wordpress without plugin using category. Showing related article in wordpress site is always good for users to attract visitors.  In many blogs people are showing the related or linked articles. Showing similier or related articles will increaze your site SEO. show related posts without wordpress plugin using category in wordpress site is always good for users to attract the visitors.

show related posts wordpress without plugin

More visitor will visit your site. For showing the related articles you need copy following code into your functions.php file.

[viral-lock message=”Code is Hidden! It’s Visible for Users who Liked/Shared This article on Facebook or Twitter or Google+. Like or Tweet this article to reveal the content.”]

// "Similier Articles"
function wpapi_more_from_cat( $title = "Similier Articles:" ) {
    global $post;
    // We should get the first category of the post
    $categories = get_the_category( $post->ID );
    $first_cat = $categories[0]->cat_ID;
    // Let's start the $output by displaying the title and opening the <ul>
    $output = '<h3>' . $title . '</h3>';
    // The arguments of the post list!
    $args = array(
        // It should be in the first category of our post:
        'category__in' => array( $first_cat ),
        // Our post should NOT be in the list:
        'post__not_in' => array( $post->ID ),
        // ...And it should fetch 5 posts - you can change this number if you like:
        'posts_per_page' => 5
    );
    // The get_posts() function
    $posts = get_posts( $args );
    if( $posts ) {
        $output .= '<ul>';
        // Let's start the loop!
        foreach( $posts as $post ) {
            setup_postdata( $post );
            $post_title = get_the_title();
            $permalink = get_permalink();
            $output .= '
<ul>
	<li>permalink . '" title="' . esc_attr( $post_title ) . '">' . $post_title . '</li>
</ul>
';
        }
        $output .= '</ul>';
    } else {
        // If there are no posts, we should return something, too!
        $output .= '<p>Sorry, this category has just one post and you just read it!</p>';
    }
    echo $output;
}

[/viral-lock]

After that open your single.php file and use following code.

wpapi_more_from_cat();
show related posts wordpress without plugin
show related posts wordpress without plugin

Using above code you can show the related articles in your wordpress site.

Show QR code in your wordpress post

QR codes are digital information which will be stored in image format. Many people are showing the QR code image in there site. You can very easily show the chart qr image in your post.

Show QR code in your wordpress post

You need to use the following code in your single.php file.

<img src="https://chart.googleapis.com/chart?cht=qr&chs=250x250&chl=<!--?php the_permalink(); ?-->" alt="QR: <!--?php the_title(); ?-->"/>
Show QR code in your wordpress post
Show QR code in your wordpress post

How to wordpress secure file upload using apache rules

WordPress tutorial, How to wordpress secure file upload using apache rules, Here we given apache rule for secure your wordpress file upload functionality.

How to wordpress secure file upload using apache rules

Website security is most important point of any website. In wordpress we need to give 777 permission to wp-content/uploads folder. Some time we don’t want to give the 777 (read, write and execute) permission to folder due to security reason but wordpress do not allow you to upload images or media files to uploads folder.

Tip: Do not give 777 permission to wp-content/uploads folder. In stead change user ownership to apache folder.

Security

What you can do is. You can restrict other file types to upload in uploads folder using simple apache rule. following code you can use in .htaccess file.


	Order Allow,Deny
	Deny from all

<FilesMatch ".(jpg|jpeg|jpe|gif|png|tif|tiff)$">
	Order Deny,Allow
	Allow from all

Using above code you can secure your uploads folder and only selected files can be pushed into uploads folder.

How to wordpress secure file upload using apache rules
How to wordpress secure file upload using apache rules

how to get post data outside loop in wordpress

WordPress hack, In this wordpress tutorial we given code and shown, how to get post data outside loop in wordpress. In wordpress theme you can get post data.

how to get post data outside loop in wordpress

Outside the loop you can get the a post data. you just need to copy paste following code in your theme file.

<?php
global $post;

$args = array( 'numberposts' => 5, 'offset'=> 1, 'category' => 1 );

$myposts = get_posts( $args );

foreach( $myposts as $post ) : setup_postdata($post); ?>
 <li>
 <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
 </li>
<?php endforeach; ?>
how to get post data outside loop in wordpress
how to get post data outside loop in wordpress

how to get parent page title in wordpress

If want to get parent page title in wordpress and show in wordpress then use following code snippet in your theme you can easily get the parent page title.

how to get parent page title in wordpress

Normally what I would do is check $post->parent and if 0 then return page title else return title of page above. Problem is that $post->parent will only go back one level. I need to use some sort of recursive function that keeps going back until $post->parent == 0.

Add following code in to your wordpress theme, functions.php file and that sit. you will done.

<!--?<span class="hiddenSpellError" pre="" data-mce-bogus="1"-->php
 global $post;
 $parent_title = get_the_title($post->post_parent);
 echo $parent_title;
?>

Using above code you can easily print the page title in wordpress theme.

how to get parent page title in wordpress
how to get parent page title in wordpress

Jetpack by WordPress.com wordpess plugin review

Jetpack is most popular wordpress plugin. Jetpack is downloaded more then 5 millions times. we have written Jetpack by WordPress.com wordpess plugin review.

Jetpack by WordPress.com

wordpress jetpack has following features:

  • Simple, concise stats with no additional load on your server. Previously provided by WordPress.com Stats.
  • Email subscriptions for your blog’s posts and your post’s comments.
  • Social networking enabled comment system.
  • Likes, allowing your readers to show their appreciation of your posts.
  • Monitor and manage your site’s activity with Notifications in your Toolbar and on WordPress.com.
  • Simple, Akismet-backed contact forms.
  • The WP.me URL shortener.
  • Hovercard popups for your commenters via Gravatar.
  • Easily embedded media from popular sites like YouTube, Digg, and Vimeo.
  • The ability to post to your blog from any email client.
  • Integration with and automatic posting to your favorite social networks including Twitter, Facebook, Tumblr, and LinkedIn.
  • For the Math geeks, a simple way to include beautiful mathematical expressions on your site.
  • A widget for displaying recent tweets. Previously provided by Wickett Twitter Widget
  • Your readers can easily share your posts via email or their favorite social networks. Previously provided by the Sharedaddy WordPress plugin.
  • Your writing will improve thanks to After the Deadline, an artificial intelligence based spell, style, and grammar checker. Previously provided by the After the Deadline WordPress plugin.
  • With Carousel active, any standard WordPress galleries you have embedded in posts or pages will launch a gorgeous full-screen photo browsing experience with comments and EXIF metadata.
  • A CSS editor that lets you customize your site design without modifying your theme.
  • A mobile theme that automatically streamlines your site for visitors on mobile devices.
  • Mobile push notifications for new comments via WordPress mobile apps.
  • The ability to allow applications to securely authenticate and access your site with your permission.
  • Creative formats for your image galleries: mosaic, circles, squares, and a slideshow view.
  • Add post sliders and other highlights to your theme with Featured Content.
  • and many more to come!

Jetpack by WordPress.com wordpess plugin review:

  • This plugin is useful for wordpress hosted and self hosted plugins.
  • Jetpack plugin has easy to configure
  • You do not need to technical knowledge to configure the Jetpack
  • It adds multiple widgets and features to your site like plus added extras, like Contact Me forms, Subscribe to this blog via Email Form, RSS feed widgets, and enough website stats
  • Only bad part about plugin is, You need to worpdress account for activating this plugin
  • This is plugin is secure and safe because it is owned by wordpress.com itself
  • Some features are not in Jetpack plugin like – photon – It will add wp.com domain in every image URL.

 

Jetpack by WordPress.com wordpess plugin review
Jetpack by WordPress.com wordpess plugin review

how disable comments on wordpress pages

We strongly recommend to disable comments on wordpress pages. Many people want to disable the page comments. Using our code disable comments for your pages. Many people want to disable the page comments. Using simple code you can easily disable the comments for your pages by default.

how disable comments on wordpress pages

Here I written simple code. Using following code you can disable the comments for your wordpress pages. you need to just put following code into your functions.php file.

<!--?<span class="hiddenSpellError" pre="" data-mce-bogus="1"-->php

function disable_comments( $posts ) {
 if ( is_page()) {
 $posts[0]->comment_status = 'disabled';
 $posts[0]->ping_status = 'disabled';
 }
return $posts;
}
add_filter( 'the_posts', 'disable_comments' );
?>
how disable comments on wordpress pages
how disable comments on wordpress pages

Disable comments on posts after certain comment count

Many people want to disable the post comments for some posts which has too many comments. Using simple code you can easily disable the comments for your posts which has many comments.

Here I written simple code. Using following code you can disable the comments which posts has more than 100 comments. you need to just put following code into your functions.php file.

<!--?<span class="hiddenSpellError" pre="" data-mce-bogus="1"-->php
$comment_count = 100;
function disable_comments( $posts ) {
 if ( !is_single() ) { return $posts; }
 if ( $posts[0]->comment_count > $comment_count ) {
 $posts[0]->comment_status = 'disabled';
 $posts[0]->ping_status = 'disabled';
 }
return $posts;
}
add_filter( 'the_posts', 'disable_comments' );
?>
Disable comments on posts after certain commment count in wordpress
Disable comments on posts after certain commment count in wordpress

how to get current user information in wordpress

In wordpress current user means, Who written current post or article.In this article we are going show you, how to get current user information in wordpress. Following methods are useful when user are logged in to wordpress CMS.

You can print the user information using following information. Retrieves the information pertaining to the currently logged in user, and places it in the global variable $current_user.

how to get current user information in wordpress

You can put following code in your theme folder.

<?php 

global $current_user;
 get_currentuserinfo();
 echo 'Username: ' . $current_user->user_login . "\n";
 echo 'User email: ' . $current_user->user_email . "\n";
 echo 'User first name: ' . $current_user->user_firstname . "\n";
 echo 'User last name: ' . $current_user->user_lastname . "\n";
 echo 'User display name: ' . $current_user->display_name . "\n";
 echo 'User ID: ' . $current_user->ID . "\n";
?>

Or you can use following code for showing the current user information

<?php&nbsp;
wp_get_current_user();&nbsp;
?>  

<?php
$user_info = get_userdata(1);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo 'Username: ' . $user_info->user_login . "\n";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo 'User roles: ' . implode(', ', $user_info->roles) . "\n";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo 'User ID: ' . $user_info->ID . "\n";
?>

For more detailed information you can visit following link:
http://codex.wordpress.org/Function_Reference/get_userdata

how to get current user information in wordpress
how to get current user information in wordpress