how to change wordpress post order category wise

When we need to re-arrange my recent post in wordpress. they go Ascending/Descending order category wise. Code for change wordpress post order category wise. We can easily achieve this using wordpress api.

how to change wordpress post order category wise

how to change wordpress post order category wise
how to change wordpress post order category wise

use following code:


<!--?php

//The Query
query_posts('cat=1,3,3&posts_per_page=15&order=ASC');

//The Loop
if ( have_posts() ) : while ( have_posts() ) : the_post();
 ..
endwhile; else:
 ..
endif;

?-->

how to add thank you message after wordpress comments

Saying thank you is always good manners. In article, i have code for, add thank you message after wordpress comments after adding comments added by users. I got the same request from many of clients for adding the thank you message after putting comments after by the user who comes to site.

It was good to have this functionality. User will remember your site and you should send the thank you email to user for adding the comment to your wordpress website. For professional sites, it is very great functionality.

add thank you message after wordpress comments

In this article I will show how to add custom message after getting comments from users. For this we going use the wordpress api. WordPress filters are very useful. You can find all wordpress hooks and filters in wp-includes/default-filters.php file.

  • Method First
add_filter('comment_post_redirect', 'redirect_after_comment');
function redirect_after_comment($location){
    $newurl = substr($location, 0, strpos($location, "#comment"));
    return $newurl . '?c=y';
}

if($_GET[ 'c' ] == 'y'){
      echo 'Thank you your comemnt';
} 

Open your functions.php file from your active wordpress theme folder. copy paste the following code in that file. This is very simple trick but still it is really useful.

  • Method Second

For this method you need to create the “Thank you” page in wordpress site than open functions.php file and put following code in that file.


// Redirect to thank you post after comment
add_action('comment_post_redirect', 'redirect_to_thank_page');

function redirect_to_thank_page() {
return 'https://purabtech.in/thank-you';
}

Note: do not forget to change your URL thank you URL from code.  Above code will work in new wordpress versions.

 

 

add thank you message after wordpress comments
add thank you message after wordpress comments

How to add ads end of wordpress RSS feed

If you want place ads in RSS feed at end. that is very easy with wordpress websites. We given simple code, Using our code, add ads end of wordpress RSS feed.

How to add ads end of wordpress RSS feed

How to add ads end of wordpress RSS feed
How to add ads end of wordpress RSS feed

Open your functions.php file from wordpress theme folder and use following code:

function insertAds_in_rss($content) {

$content = $content.' Your ads code goes will here';

return $content;}

add_filter('the_content_feed', 'insertAds_in_rss');

add_filter('the_excerpt_rss', 'insertAds_in_rss');

How to block your rss feed in wordpress website

In that situation you need to use following techniques. We given tricks, techniques and code for block your rss feed in wordpress website. Many people does not want to show their websites need to be cached or indexed by search engine. In that situation you need to use following techniques.

How to block your rss feed in wordpress website

How to block your rss feed in wordpress website
How to block your rss feed in wordpress website

First create the robots.txt file and put following code in that file.

User-agent: *

Disallow: /

You need to open functions.php file for disabling the rss feed from your website.
Put following code in that file.

function disable_rss_feed() {
    wp_die( __('No Rss feed are available,please visit our <a href="'. get_bloginfo('url') .'">website</a>!') );
}

add_action('do_feed', 'disable_rss_feed', 1);
add_action('do_feed_rdf', 'disable_rss_feed', 1);
add_action('do_feed_rss', 'disable_rss_feed', 1);
add_action('do_feed_rss2', 'disable_rss_feed', 1);
add_action('do_feed_atom', 'disable_rss_feed', 1);

wordpress 2.8.3 and 2.8.4 versions are under attack

If you are using the wordpress for your website or blog. Please do check your wordpress version because We got very serious news about wordpress older versions. I do got news about wordpress version 2.8.3 and 2.8.4. They are in serious trouble. There are so many sites are hacked and affected which is using wordpress 2.8.3 and 2.8.4 versions.

wordpress 2.8.3 and 2.8.4 versions are under attack

wordpress 2.8.3 and 2.8.4 versions are under attack
wordpress 2.8.3 and 2.8.4 versions are under attack

First I will tell you how can you check your wordpress website is hacked or not.

When you saw strange keywords in URL like  “eval” and “base64_decode.”

Check your Users in wordpress admin panel If you saw any new unwanted users then you really need to worry about.

Some time you did not able to access your wordpress admin panel. Then immediately take action and call your system admin or web development company.

I suggest first upgrade your wordpress version to greater than wordpress 2.8.6. I personally use the 2.8.6 and I did not found any issues yet.

Keep your admin passwords and database and ftp passwords as strong as possible.  Use special characters and numbers in password.

My personal suggestion is keep using the latest wordpress version.

How do we protect wordpress admin panel and secure it

WordPress admin security is very important. Many people are always take a shared hosting. we given Information about How do we protect wordpress admin panel.  Many people are always take a shared hosting for publishing the wordpress website.

With shared hosting or dedicated you should always think about hack proof wordpress admin panel. So no one can misuse your worepress admin panel. Here in this article I will give you some very nice tips about, how to protect our wordpress admin panel.

protect wordpress admin panel
protect wordpress admin panel

protect wordpress admin panel

1. Create very strong password

Always create a very strong password for your admin user. You should add some special characters and numbers in your password. Your password should be 10 digit minimum and not related to your name or surname.

Main important think is dont disclose your password to anyone.

2. Limit wordpress admin access via IP address

You can use the .htaccess file for limiting the wordpress admin panel for specific ip addresses only. Use following code for that.

<files “wp-login.<span=”” class=”hiddenSpellError” pre=”” data-mce-bogus=”1″>php”>
Order Deny,Allow
Deny from all
Allow from Your.IP.Address

allow from 192.168.2.45

</Files>
[/php]

3. Avoid the “admin” Username

You should always avoid the admin username to login. You can easily achieve this. First create another super admin with another name and open your functions.php file from wordpress theme folder and use following code.


add_filter(‘login_errors’,create_function(‘$a’, “return null;”));

There are some very nice plugins also available for providing the wordpress security your wordpress website. Here are few:

http://wordpress.org/extend/plugins/one-time-password/

http://wordpress.org/extend/plugins/semisecure-login-reimagined/

http://www.bad-neighborhood.com/login-lockdown.html

http://wordpress.org/extend/plugins/stealth-login/

How to hide update message from wordpress admin panel

In this article, we given code and shown you. How to hide update message from wordpress admin panel. Some times Admin update message are interpreting on dashboard.

When new wordpress version came. we got a message in wordpress admin panel as follows:

WordPress ….. is available! Please update.

How to hide update message from wordpress admin panel

Many people does not want to see that message or hide this message from wordpress admin panel

How to hide update message from wordpress admin panel

Just Open functions.php file from wordpres theme and put following code in that file:


add_action('admin_menu','hide_update_message');
 function hide_update_message()
 {
 remove_action( 'admin_notices', 'update_nag', 3 );
remove_filter( 'update_footer', 'core_update_footer' );

}

This code will run in wordpress and wordpressMU also.

how to register multiple sidebar in wordpress

Many wordpress developers and PHP developers who are new in to wordpress development. They really searching for how to add a dynamic or multiple side in wordpress theme. many sidebar or widget are very important to add in any wordpress theme for seo purpose also so you can add the widgets using our code sample.

register multiple sidebar in wordpress

Many wordpress developers got requirement to add separate sidebar for each page or any specific page and that sidebar need to be controlled by wordpress admin.

In this tutorial I will show you how to simply add the multiple or dynamic sidebar to wordpress theme. I really think creating the or putting separate css and options in  the sidebar and admin has no control over the sidebar.

Just use my code to create the multiple sidebar in wordpress theme. This following function is provided by wordpress api only. Open your functions.php file from your wordpress theme folder


<!--?<span class="hiddenSpellError" pre="" data-mce-bogus="1"-->php
 if(function_exists('register_sidebar'))
 register_sidebar(array(
 'name' => 'Home Page', // The sidebar name you can choose as per your choice to register
 'before_widget' => 'PUT YOUR OPENING CSS DIV AND CSS CLASSES AND IDS HERE',
 'after_widget' => 'CLOSE THE DIV',
 'before_title' => '<h2>',
 'after_title' => '</h2>',
 ));
?>

This is sample code for multiple pages your can use following code:


<!--?<span class="hiddenSpellError" pre="" data-mce-bogus="1"-->php
     // Home Page sidebar
     if(function_exists('register_sidebar'))
          register_sidebar(array(
          'name' => 'Home Page',
          'before_widget' => 'PUT YOUR OPENING CSS DIV AND CSS CLASSES AND IDS HERE',
          'after_widget' => 'CLOSE THE DIV',
          'before_title' => '<h3>',
          'after_title' => '</h3>',
     ));
     // Blog Page sidebar
     if(function_exists('register_sidebar'))
          register_sidebar(array(
          'name' => 'Blog Page',
          'before_widget' => 'PUT YOUR OPENING CSS DIV AND CSS CLASSES AND IDS HERE',
          'after_widget' => 'CLOSE THE DIV',
          'before_title' => '<h3>',
          'after_title' => '</h3>',
     ));
     // Contact us Page sidebar
     if(function_exists('register_sidebar'))
          register_sidebar(array(
          'name' => 'Contact Page',
          'before_widget' => 'PUT YOUR OPENING CSS DIV AND CSS CLASSES AND IDS HERE',
          'after_widget' => 'CLOSE THE DIV',
          'before_title' => '<h3>',
          'after_title' => '</h3>',
     ));
     // About us Page sidebar
     if(function_exists('register_sidebar'))
          register_sidebar(array(
          'name' => 'About us',
          'before_widget' => 'PUT YOUR OPENING CSS DIV AND CSS CLASSES AND IDS HERE',
          'after_widget' => 'CLOSE THE DIV',
          'before_title' => '<h3>',
          'after_title' => '</h3>',
     ));

?>

Here is Big question, How can you call the different sidebars and manage it. Go to wordpress admin and you will find and four side bars present in widgets sections as per this code. You can just drag and drop the widgets as your choice.

Open your sidebar.php file put following code in that file.

<?php
is_page('Home Page') {
     if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('Home Page')) :
     endif;
}
?>
how to register multiple sidebar in wordpress
how to register multiple sidebar in wordpress

You can use the following type of code in your sidebar.php file as per your condition. If you have any issues get back to me.

how to remove blog or category word from wordpress URL

Many times wordpress developer got requirement to remove the blog or category word from wordpress url. Code for remove blog or category word from wordpress.

how to remove blog or category word from wordpress URL

Many people and wordpress developer want to remove the blog or category wordpress from URL. This is really good for seo also. Many times wordpress developer got requirement to remove the blog or category word from wordpress url.

how to remove blog or category word from wordpress URL
how to remove blog or category word from wordpress URL

In this tutorial I will let you know how can you easily achieve this requirement. There is two-way to achieve this requirement. You can use the .htaccess file for fulfill this requirement.

Note: Apache mod_rewrite rule is must enable to with your Apache web server.

Open your .htaccess file which is present in your root folder of web hosting server. If not then create this file put it.

You can use the permanent redirect rewrite apache rule to achieve this. open your .htaccess file put following lines in that file


RewriteEngine On
RewriteBase /

#This rewrite rule we added for removing the category wordpress from URL
RewriteRule ^category/(.+)$ http://www.purabtech.in/files/$1 [R=301,L]

#This rewrite rule we added for removing the blog word wordpress from URL

RewriteRule ^blog/(.+)$ http://www.purabtech.in/files/$1 [R=301,L]

You can achieve this by changing in the code also. Use the following code do this changes. Open your theme folder and functions.php file and put following code in that file.


function remove_blog_word($without_blog_word_permalink)
{

if(!preg_match("/^\/blog\//",$without_blog_word_permalink))
return $without_blog_word_permalink;

$new_permalink=preg_replace ("/^\/blog\//","/",$without_blog_word_permalink );
return $new_permalink;

}

function remove_category_word($without_category_word_permalink)
 {

 if(!preg_match("/^\/category\//",$without_category_word_permalink))
 return $without_blog_word_permalink;

 $new_permalink=preg_replace  ("/^\/category\//","/",$without_category_word_permalink );
 return $new_permalink;

 }

add_filter("pre_update_option_permalink_structure","remove_blog_word");

add_filter("pre_update_option_permalink_structure","remove_category_word");

Just put above lines in your functions.php file and that will solve your issue.

How to show recent posts without wordpress plugin

When we are work with wordpress theme. So many times we want to show recent posts without wordpress plugin in wordpress theme.  Many people suggest to use wordpress plugin for showing the recent post.

How to show recent posts without wordpress plugin

But I suggest not to use any wordpress plugin for showing the recent posts in wordpress theme.

In this tutorial I will tell very simple technique to show recent posts. Following code you can use in your sidebar.php or in footer.php or anywhere as per your theme requirement.

Just put following code in your theme file. You just need to change the showposts count as per choice.


<?php
 $recent_posts = new WP_Query('showposts=15');
 while ($my_query->have_posts()) : $my_query->the_post();$do_not_duplicate = $post->ID;
?>

Your recent post will look this. You just need to customize css as per your wordpress theme.

show recent posts without wordpress plugin
show recent posts without wordpress plugin