How to Make Secondary Menu in wordpress

Add the below Code in to function.php

register_nav_menu( 'secondary', __( 'Secondary Menu', 'twentytwelve') );

Use the below code to call the secondary Menu

<?php wp_nav_menu( array( 'theme_location' => 'secondary', 'menu_class' => 'nav-menu' ) ); ?


1. Function.php

Seconday Menu

2.  Ex. footer.php

sencodary Menu1


How To Limit Words and Characters in content WordPress

How To Limit Words and Characters in content WordPress

1. Words Length:

Remove  the <?php the_content();?>  insert the below code

 <?php $content = get_the_content();
  $trimmed_content = wp_trim_words( $content, 60, '<a href="'. get_permalink() .'">...[ read more ]</a>' ); ?>
  <p><?php echo $trimmed_content; ?></p>
(Change the 60 to your desire words length)

 2. Character Length :

Remove  the <?php the_content();?>  insert the below code

<?php echo substr(strip_tags($post->post_content), 0, 46);?>
//(Change the 46 to your desire string length)

How to get custom values outside Loop

 How to get custom values outside Loop

global $wp_query;
$postid = $wp_query->post->ID;
echo get_post_meta($postid, 'Your-Custom-Field', true);


global $wp_query;
$postid = $wp_query->post->ID;
$img = get_post_meta($postid, 'sidebar_image', true);
echo "<img src ='$img'>";
<img src="<?php bloginfo("template_url")?>/images/care.jpg" />

How to Get the Dynamic Categories related Posts

How to  Get the Dyanmic Categories:

Here small snippet code is avialble for get categories related  posts

1. You have to give the page name and category name should be same

2. Add below code where you want..and than refresh page . you will get the post related categories.

<?php query_posts('category_name='.get_permalink().'&post_status=publish,future');?>

Function Reference – Content url

The content_url template tag retrieves the url to the content area for the current site with the appropriate protocol, ‘https’ if is_ssl() and ‘http’ otherwise.

WordPress Directories:
home_url() Home URL
site_url() Site directory URL or
admin_url() Admin directory URL
includes_url() Includes directory URL
content_url() Content directory URL
plugins_url() Plugins directory URL
theme_url() Themes directory URL
wp_upload_dir() Upload directory URL