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 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

How to show featured image in wordpress admin panel list

Featured images are very important feature of wordpress. Many blogger use the featured images on top. With watching the featured images user got idea about blog post or your article. Some time we miss to upload the featured image.

How to show featured image in wordpress admin panel list

But in post list cannot able to see the featured image in admin panel.

I found very nice wordpress plugin which is helpful to show the featured image in admin panel.

Featured Image Column – Adds a column to the edit screen with the featured image if it exists.

This plugin has no options. It simply adds a column before the title (far left) the show’s the posts featured image if it’s supported and/or exists.

Add a defualt image simply by filtering you own image in. Use featured_image_column_default_image or filter your own CSS by using featured_image_column_css.

Add support for a custom default image

How to show featured image in admin panel list - in post list - for wordpress
How to show featured image in admin panel list – in post list – for wordpress
function my_custom_featured_image_column_image( $image ) {
    if ( !has_post_thumbnail() )
        return trailingslashit( get_stylesheet_directory_uri() ) . 'images/featured-image.png';
}
add_filter( 'featured_image_column_default_image', 'my_custom_featured_image_column_image' );

Add your own CSS to change the size of the image.

/**
 * @use '.featured-image.column-featured-image img {}'
 */
function my_custom_featured_image_css() {
    return trailingslashit( get_stylesheet_directory_uri() ) . 'css/featured-image.css'; //URL to your css
}
add_filter( 'featured_image_column_css', 'my_custom_featured_image_css' );

I found this plugin is really helpful to me. Using this plugin I can easily check the featured image.

How to make empty wordpress trash automatically

Sometimes we create pages and posts which are unwanted. In this article, I given code for make empty wordpress trash automatically. Using code deleted items will automatically delete from trash. Open your wp-config.php file which is in the root directory of wordpress installation.

How to make empty wordpress trash automatically

How to make empty wordpress trash automatically
How to make empty wordpress trash automatically
define('EMPTY_TRASH_DAYS', 7 );

Above code will delete the comments from trash section after every seven days.

Seven days are safe to keep trash. This is simple but good option to keep in your wordpress blog.

Display the authors in dropdown menu using wp_dropdown_users – Hook/Filter

One of my client faced issue with Autor drop down which is in Admin section.

Display the authors in dropdown menu using hooks.

While creating the New post there was problem with the Author field. There are hundreds of irrelevant selections (users) and it’s difficult to select the right one.

WordPress is by default showing all the users in author drop down. I don’t want to show the other users in author drop down.

Display the authors in a dropdown menu
Hook/Filter – In wordpress Admin -Add new Post section -Display the authors in a dropdown menu using wp_dropdown_users One of my client faced issue with Autor drop down which is in Admin section. Display the authors in a dropdown menu using hooks

I searched for wp_dropdown_users hook or filter. But I did not found any proper solution.

Following articles are found helpful to me.
http://wordpress.org/support/topic/filter-for-post-quick-edit-author-drop-down
http://codex.wordpress.org/Function_Reference/wp_dropdown_users

Using that code I modified the code and I am able to fix the issue. You can put following code in to functions.php file.

 /*
 * Hook for showing Admin and Author in Add new Post - Admin section dropdown menu
 */
function wpapi_override_wp_dropdown_users($output) {
    global $post, $user_ID;
    //get the Admin-role users IDs
    $admins = getUsersWithRole('admin');
    //get the author-role users IDs
    $authors = getUsersWithRole('author');
    //merge the array
    $result = array_merge($admins, $authors);

    //array converted into comma seprated string
    $authorsall = implode(",", $result);

    // return if this isn't the theme author override dropdown
    if (!preg_match('/post_author_override/', $output))
        return $output;

    // return if we've already replaced the list (end recursion)
    if (preg_match('/post_author_override_replaced/', $output))
        return $output;

    // replacement call to wp_dropdown_users
    $output = wp_dropdown_users(array(
        'echo' => 0,
        'name' => 'post_author_override_replaced',
        'selected' => empty($post->ID) ? $user_ID : $post->post_author,
        'include_selected' => true,
        'include' => $authorsall
    ));

    // put the original name back
    $output = preg_replace('/post_author_override_replaced/', 'post_author_override', $output);

    return $output;
}

add_filter('wp_dropdown_users', 'wpapi_override_wp_dropdown_users');

/*
 * Find User IDs by Role
 */

function getUsersWithRole($role) {
    $wp_user_search = new WP_User_Search($usersearch, $userspage, $role);
    return $wp_user_search->get_results();
}

Using above code, you can load multiple role users in author drop down.

prevent wordpress images hotlinking but allow google

Here in wordpress tutorial, How to prevent wordpress images hotlinking but allow google. Steeling the blog images is very major issue in wordpress sites. Sometimes people are just linking the your site images in there site.You can read more about linking in above article.

prevent wordpress images hotlinking but allow google

http://en.wikipedia.org/wiki/Inline_linking

Some sites are using your images and your bandwidth. If you are still want to use other images then use in your server and give credit to there owner sites.

prevent wordpress images hotlinking but allow google
prevent wordpress images hotlinking but allow google

I already wrote about this.

How to protect your images directly accessing through server by apache

Hotlinking’s legality, purely in regard to bandwidth theft:
http://www.phenomenalwomen.com/donteventhinkaboutit/
http://www.yourhtmlsource.com/sitemanagement/bandwidththeft.html
http://www.boogiejack.com/copyband.html
http://www.webprogramming360.com/2011/05/what-is-bandwidth-theft.html

how to disable cron job in wordpress

Before every post visit wordpress cron is running and taking too much bandwidth.  So we given trick and code to disable cron job in wordpress, which will disable wordpress cronjob.  if you have a lot of visitors it can be a problem. I am convinced this is the reason why my admin has become glacially slow and my site often crashes when making edits.

how to disable cron job in wordpress

Disable the wp-cron.php

you need to add the code to your wp-config.php file.


define('DISABLE_WP_CRON', 'true');

If you have shared hosting then add the following cron job


php -q wp-cron.php

If you have your own server then you need to add the cronjob in crontab


* */1 * * *wget https://purabtech.in/wp-cron.php

how to disable cron job in wordpress
how to disable cron job in wordpress