NginX Rule for WordPress Mu with Pretty Url

I am using wordpressmu 2.6.5, quite old version. Three month back i moved our site Apache to Nginx. Now these day nobody use wordpress mu. Still article can be used for wordpress multisite.

NginX Rule for WordPress Mu with Pretty Url

Nginx i am using for Rails and WordPressmu application.

I am able to run wordpressmu and Clean Urls(Pretty Url) successfully. I am using Fedora 9 as OS.
“/usr/share/nginx/html/wordpress” – This is my path where i installed WordPressmu

Here is my Nginx code:


server {
listen 80;
server_name localhost.localdomain;
# access_log logs/site.access.log;

location ~* ^.+\.(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js)$
{
root /usr/share/nginx/html/wordpress;
rewrite ^/.*(/wp-admin/.*\.(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js))$ $1 last;
rewrite ^/.*(/wp-includes/.*\.(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js))$ $1 last;
rewrite ^/.*(/wp-content/themes/.*\.(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js))$ $1 last;
rewrite ^/.*(/wp-content/.*\.(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js))$ $1 last;
rewrite ^.*/files/(.*(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js))$ /wp-content/blogs.php?file=$1 last;
expires 10d;
break;
}

location / {
root /usr/share/nginx/html;
index index.php;

rewrite ^.*/.*/files/(.*) /wordpress/wp-content/blogs.php?file=$1;
if (!-e $request_filename) {
rewrite ^.+?(/wp-.*) /wordpress$1 last;
rewrite ^.+?(/.*\.php)$ /wordpress$1 last;
rewrite ^(.+)$ /wordpress/index.php?q=$1 last;
break;
}

fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;

fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;

fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;

fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param REDIRECT_STATUS 200;
include fastcgi_params;

}

location = /50x.html {
root /var/www/nginx-default;
}

}

This code is working fine for me.

How to add HTML code on WordPress home page

Some time we want to show Some custom text or HTML code on home page. In this article we given tricks and steps to add HTML code on WordPress home page.

How to add HTML code on WordPress home page

  • First method

you need go to wordpress admin panel.Create page with home name. Add your HTML or custom text in that page.

Go to Setting->reading section. There is “Front page displays”  section. We can found following two radio box over there.

  • Your latest posts
  • A static page (select below)

Select “A static page (select below) ” radio box. Than from “Front page:” select box, select the Home page. That sit.

How to add HTML code on WordPress home page
How to add HTML code on WordPress home page
  • Second Method

If you want to add some different text or HTML code, than you need open functions.php file which you found in wordpress themes folders. Just copy and paste following code in that file.


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

if (is_home() {
echo "HTML CODE GOES HERE OR TEXT";

}

?>

Note: You need replace HTML code. I used sample text in code.

Have fun!

How to fetch Feedburner Subscriber Count in wordpress

We all are using the feedburner button in wordpress sites. In this article showing, How to fetch Feedburner Subscriber Count in wordpress website using our code.

How to fetch Feedburner Subscriber Count in wordpress

Just copy paste the following code in your sidebar.php file(This file you will find in your template folder.)

<?php

//You need to change the uri parameter to your website name
$whaturl=”http://api.feedburner.com/awareness/1.0/GetFeedData?uri=wordpressapi/ZoqV”;

//Initialize the Curl for using the feedburner api
$wordpressapi = curl_init();

//Set curl to return the data instead of printing it to the browser.
curl_setopt($wordpressapi, CURLOPT_RETURNTRANSFER, 1);

//Set the URL
curl_setopt($wordpressapi, CURLOPT_URL, $whaturl);

//fetching data
$data = curl_exec($wordpressapi);

//Closing connection
curl_close($wordpressapi);
$xml = new SimpleXMLElement($data);
$fbcount = $xml->feed->entry[‘circulation’];
echo $fbcount;
//end get cool feedburner count
?>

Echo $fbcount will print the feed Subscriber count.

add custom header to different categories in WordPress

wordpress tutorial for add custom header, footer, or sidebar for different categories in WordPress. we have given simple conditinal code which need to use in your theme file.

add custom header to different categories in WordPress

If you want to add the different header for each category then use the following code in your index.php where “get_header()” method is called.

Create the Header-new_category.php file and put your header code in that file as per requirement.

For sidebar use this code:


<?php if (is_category(‘new_category’)) {
get_header(' new_category ');
} else {
get_header();
} ?>

Create the Header-new_category.php file and put your header code in that file as per requirement.

For sidebar use this code:


<?php if (is_category('New_category')) {
get_sidebar('new_category');
} else {
get_sidebar();
} ?>

Create the sidebar-new_category.php file and put your sidebar code in that file as per requirement.

For Footer use this code:


<?php if (is_category('New_category')) {
get_footer('new_category');
} else {
get_footer();
} ?>

 

 

Create the footer-new_category.php file and put your footer code in that file as per requirement.

Cheat Sheets for creating WordPress Themes and Plugins

Here is the list of cheat sheets which are very useful when your developing new theme or plugin. For wordpress theme developer and plugin developers cheat sheets are very important. We collected the nice collection Cheat Sheets for creating WordPress Themes and Plugins.

Cheat Sheets for creating WordPress Themes and Plugins

WordPress Theme Development Checklist

Download PDF : Download Cheat Sheet »
Source : http://startbloggingonline.com

WordPress Theme Development Checklist

WordPress CheatSheet

Download PDF : Download Cheat Sheet
Source : andywibbels.com

WordPress CheatSheet

The WordPress Help Sheet

Download PDF : Download Cheat Sheet
Source : http://www.fylrr.com

The WordPress Help Sheet

WordPress SEO Cheat Sheet

Download PDF : Download Cheat Sheet
Source : tekka.de

Wordpress SEO Cheat Sheet

WordPress Template Tags

Download PDF : Download Cheat Sheet
View HTML Version : View HTML Cheat Sheet
Source : bueltge.de

WordPress Template Tags

WP Widget Cheat Sheet

Download PDF : Download Cheat Sheet
Source : bueltge.de

WP Widget Cheat Sheet

WordPress Loop

Download PDF : Download Cheat Sheet
Source : bueltge.de

WordPress Loop

WP Plugin API Cheat Sheet

Download PDF : Download Cheat Sheet
Source : bueltge.de

WP Plugin API Cheat Sheet

How to show or exclude Certain Categories in a Menu – WordPress

If you want show only some categories in wordpress menu than use following command in header.php.

<ul style=”float:left; width:840px;”>
php wp_list_categories(‘orderby=name&include=5,4,8,9,52,65,35’); ?>
ul>

If you want exclude some categories in wordpress menu than use following command in header.php.

840px;”>
php wp_list_categories(‘orderby=name&exclude=5,4,8,9,52,65,35’); ?>
</ul>

Following Options we can use with “wp_list_categories” method.

<?php wp_list_categories( $args ); ?>

args = array(
'show_option_all' => ,
'orderby' => 'name',
'order' => 'ASC',
'show_last_update' => 0,
'style' => 'list',
'show_count' => 0,
'hide_empty' => 1,
'use_desc_for_title' => 1,
'child_of' => 0,
'feed' => ,
'feed_type' => ,
'feed_image' => ,
'exclude' => ,
'exclude_tree' => ,
'include' => ,
'current_category' => 0,
'hierarchical' => true,
'title_li' => __( 'Categories' ),
'number' => NULL,
'echo' => 1,
'depth' => 0 ); ?>

 

By default, the usage shows:

  • No link to all categories
  • Sorts the list of Categories by the Category name in ascending order
  • Does not show the last update (last updated post in each Category)
  • Displayed in an unordered list style
  • Does not show the post count
  • Displays only Categories with posts
  • Sets the title attribute to the Category Description
  • Is not restricted to the child_of any Category
  • No feed or feed image used
  • Does not exclude any Category and includes all Categories
  • Displays the active Category with the CSS Class-Suffix ‘ current-cat’
  • Shows the Categories in hierarchical indented fashion
  • Display Category as the heading over the list
  • No SQL LIMIT is imposed (‘number’ => 0 is not shown above)
  • Displays (echos) the categories
  • No limit to depth
  • All categories.

Show Random Posts on page with WordPress

If you want to show random posts each time a client visits. There are many wordpress plugins which will give similar functionality. We have simple code for showing random posts which you need add in your wordpress theme.

Show Random Posts on page with WordPress

You need to create random.php page in your template.  In that page just copy paste the following code:


<!--?<span class="hiddenSpellError" pre="" data-mce-bogus="1"-->php
query_posts(array('orderby' => 'rand', 'showposts' => 1));
if (have_posts()) :
while (have_posts()) : the_post(); ?>
<h1>php the_permalink() ?>"><!--?php the_title(); ?--></h1>
<!--?<span class="hiddenSpellError" pre="" data-mce-bogus="1"-->php the_content(); ?>

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

Than create page through wordpress admin panel and select the random page template.

random-wordpress-posts
Show Random Posts on page with WordPress

How to add flash intro in sites and flash with wordpress

If want to ingrate flex or flash with wordpress. Using following steps and code you can add the flash player or flex in your wordpress theme.

 

Many wp developer are looking for wordpress flash header, wordpress flash gallery, wordpress flash player, wordpress flash intro. They want to integrate flex or flash with wordpress. Using following steps and code you can add the flash player or flex in your wordpress theme.

flash with wordpress

 

Follow my steps to create flash intro in wordpress sites.

1. Create file named intro.php and just copy paste following code:

[viral-lock message=”Solution 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.”]

<?php

/*

Template Name: intro

*/

if (have_posts()) : while (have_posts()) : the_post();
the_content();
endwhile; endif;

?>

[/viral-lock]

2. Upload intro.php file in your active theme folder.

3. Login to wordpress admin area. Click on Pages- >Add new button

4. Page title shoule be “intro” and use html mode and copy paste the your flash intro code in that page.

flash with wordpress
flash with wordpress

5. In attribute section you will find the Template option. Choose the intro option and publish the page.

flash with wordpress
How to add the flash intro in wordpress sites, flash with wordpress

 

6. Go to Setting->Reading tab and Choose the Static page check box and select the “intro” option for “Front page” and click on save changes button. That sit

Here is some useful articles link from wordpress. If you want to show pdf in post on wordpress  and  add feedburner subscribe popup to wordpress. There all types of wordpress tutorial can be found in this site.

 

solution for plugins are not working on wordpress theme

solution for plugins are not working on wordpress theme. Whenever you developing the new theme. You need to add following code in your theme file.

solution for plugins are not working on wordpress theme

</p>
wp_head();

Goes in the HTML <head> element of a theme; header.php template. Example plugin use: add javascript code.

Usage: <?php do_action('wp_head'); ?>

-or- <?php wp_head(); ?>

wp_footer

Goes in the “footer” of a theme; footer.php template. Example plugin use: insert PHP code that needs to run after everything else, at the bottom of the footer.

Usage:


<tt><?php do_action('wp_footer'); ?></tt>

-or-

</tt>

<tt><?php wp_footer(); ?></tt>

wp_meta();

 

Typically goes in the <li>Meta</li> section of a theme's menu or sidebar; sidebar.php template. Example plugin use: include a rotating advertisement or a tag cloud.

Usage:


<tt><?php do_action('wp_meta'); ?></tt>

-or-

</tt>

<tt><?php wp_meta(); ?></tt>

comment_form

Goes in comments.php and comments-popup.php, directly before the comment form's closing tag (</form>). Example plugin use: display a comment preview.

Usage:

</tt>

<tt><?php do_action('comment_form', $post->ID); ?></tt>

Note: don’t forget to add wp_head, wp-footer and wp_meta methods in you theme.

How to set different layout for each category in WordPress

In this article we given full steps and code for How to set different layout for each category in WordPress. Which you need to use in your wordpress theme.

How to set different layout for each category in WordPress

Using following code you can able to set different layout for each category.

Just create the category.php file or already existed then open that file and use following code in that file.


<?php

if (is_category(10)) {

// looking for category 10 posts

include(TEMPLATEPATH . '/layout2.php');

// or you can use “get_cat_id(’category_name’)” instead of category id

} else {

// put this on every other category post

include(TEMPLATEPATH . '/layout1.php');

}

?>

Here we are calling the layout 2 for category 10.

Have fun!