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

wordpress database migration steps

WordPress domain migration is every time required. We given simple wordpress database migration steps. Using following steps you can do domain migration. Whenever you need to push wordpress site local box to production or qa box. you need to change the domain name. I given the simple steps for wordpress database migration. Using following steps you can do the wordpress domain migration.

wordpress database migration steps

First go to wp-config.php file and change database name(what you want)
1. wp_1_options -Table name
option_name column – change(siteurl and home)

2. wp_blogs- Table name
domain column – change

3. wp_site- Table name
domain column – change

4. wp_usermeta
meta_key column – change(source_domain)

use this for
changing all post path and image path
UPDATE wp_1_posts SET post_content = REPLACE(post_content, ‘siwan.wordpress.com’, ‘localhost.localdomain’);

Following Articles are helpful to do the wordpress domain migration.

https://purabtech.in/mysql-queries-wordpress-website-migration/

https://purabtech.in/wordpress-migration-hosting-service-domain/

find replace content in post wordpress

Some times we need to change specific text in wordpress. Using mysql database query or PHPmyadmin interface, you can find replace content in post wordpress. We have given mysql query for replacing the content using database.

find replace content in post wordpress

Use this query for wordpress users


UPDATE wp_1_posts SET post_content = REPLACE(post_content, 'www.test.com', 'www.secondtest.com');

Use this query for wordpress

UPDATE wp_posts SET post_content = REPLACE(post_content, 'www.test.com', 'www.secondtest.com');

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!

How to create simple wordpress theme

If you are new to develop wordpress theme then just use following steps to create the theme. Here we given very simple steps to create simple wordpress theme. Just follow our steps and create basic and simple wordpress theme.

How to create simple wordpress theme

For wordpress theme only two files are required.

  1. style.css
  2. index.php

Only with these two files you are able to create the basic theme of wordpress

How above file should be written. Following necessary code you need to put in that file.

Style.css

/*
Theme Name: WordPressapi
Theme URI: wordpressapi-homepage
Description: a-brief-description of theme
Author: your-name
Author URI: your-URI
Template: use-this-to-define-a-parent-theme--optional
Version: a-number--optional
.
General comments/License Statement if any.
.
*/
Under this you can put your css code.

Index.php

<?php

if (have_posts()) : while (have_posts()) : the_post();

//following line will fetch the post and page code.
the_content();
endwhile; endif;

?>