Custome Menubar Support in wordpress


The navigation menu feature, introduced in WordPress 3.0, allows for the intuitive creation and maintaining of navigation menus in themes.
At the very least, a standard theme will need a main navigation menu, perhaps in the header and a secondary navigation menu in the footer. To do this, we will register those two menus “Main Menu” and “Secondary Menu”
While this isn’t a particularly new feature, its still nice to wrap it in an if function_exists() just in case the user is stuck in a pre 3.0 installation:
In the functions.php file, include the following:
if ( function_exists( 'register_nav_menus' ) ) {
 register_nav_menus(
  array(
    'main_menu' => __( 'Main Menu', 'cake' ),
    'secondary_menu' => __( 'Secondary Menu', 'cake' ),
  )
 );
}
Now that the Menus are registered, we need to tell the theme where to output them. We’d like the Main Menu to appear in our header. So, in our header.php file, we include the following code:
<?php if ( has_nav_menu( 'main_menu' ) ) { ?>
 <?php $defaults = array(
   'theme_location'  => 'main_menu',
   'menu'            => '', 
   'container'       => false, 
   'echo'            => true,
   'fallback_cb'     => false,
   'items_wrap'      => '<ul id="%1$s"> %3$s</ul>',
   'depth'           => 0 );
   wp_nav_menu( $defaults );
 ?>
<?php } else { ?>
 <ul>
   <?php wp_list_pages('title_li='); ?>
 </ul>
<?php } ?>
First, we check to see if we have a menu called ‘main_menu’ defined and if we do, we insert its contents here, otherwise we fallback to the default wp_list_pages() which we can further customize to display the links as we need.
If you’d like even further customization of the menu, see the WordPress codex page on wp_nav_menu() function.
We want the secondary menu to appear in the footer, so we open up the footer.php and include the following code:
<?php if ( has_nav_menu( 'secondary_menu' ) ) { ?>
 <?php $defaults = array(
   'theme_location'  => 'secondary_menu',
   'menu'            => '', 
   'container'       => false, 
   'echo'            => true,
   'fallback_cb'     => false,
   'items_wrap'      => '<ul id="%1$s"> %3$s</ul>',
   'depth'           => 0 );
   wp_nav_menu( $defaults );
 ?>
<?php } else { ?>
 <ul>
   <?php wp_list_pages('title_li='); ?>
 </ul>
<?php } ?>

Displaying Common Information using common functions in wordpress?


Now let’s move on to some more functions we can use inside the loop. Many of these functions can only be used inside the loop and may not work if used outside of it.
Display the title of the post:
<?php the_title(); ?>
Display the URL of the post:
<?php the_permalink(); ?>
Display the content of the post:
<?php the_content(); ?>
Display the excerpt of the post:
<?php the_excerpt(); ?>
Display the category of the post:
<?php the_category(); ?>
Display the tags used in the post:
<?php the_tags(); ?>
Display the time the post was published (uses PHP date formatting as a parameter):
<?php the_time(); ?>

How to get the url of current theme?

Getting the URL to the Current Theme

To grab the current theme directory’s URL, you can use the template_url parameter. This makes your WordPress themes more flexible so that when you change the domain name or use it in multiple domain names you don’t have to worry about changing anything that references the theme’s location. You can use this parameter a number of ways, such as for referencing custom external stylesheets, images, and JavaScript libraries that are inside the theme directory.
<?php bloginfo('template_url'); ?>

How to add google analytic code in wordpress?

1.<?php
2.add_action('wp_footer''add_googleanalytics');
3.function add_googleanalytics() { ?>
4.// Paste your Google Analytics code here
5.<?php } ?>



paste this code in your theme function file  (default: function.php)

How to get a site url in Wordpress code?

Getting the Site’s URL

Let’s say your site’s URL is http://example.com. If you want to print this out in the source, you can use the url parameter.
<?php bloginfo('url'); ?>
This works great for absolute link references. For example, if you wanted to reference your logo (let’s say the file name is logo.png) that is in a directory called images, you would do the following:
<img src="<?php bloginfo('url'); ?>/images/logo.png" />
The above outputs:
<img src=" http://example.com/images/logo.png" />