You can use this code to fetch the page details in single.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="post">
<h2><?php the_title(); ?></h2>
<div class="entry">
<?php the_content(); ?>
</div>
</div>
<?php endwhile; else: ?>
<?php _e('Sorry, no posts matched your criteria.'); ?>
<?php endif; ?>
You can use this code to fetch the page details in page.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
<?php if (have_posts()) : while (have_posts()) : the_post(); ?> <div class="post"> <h2><?php the_title(); ?></h2> <div class="entry"> <?php the_content(); ?> </div> </div> <?php endwhile; endif; ?>
Adding custom menu is a fantastic way to make your wordpress theme flexible. Its actually very simple.
Follow these steps below to activate custom menu option in any of your wordpress theme.
First open functions.php and add below code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
add_theme_support('menus');
add_action( 'init', 'register_my_menus' );
function register_my_menus() {
if ( function_exists('register_nav_menus') ) {
register_nav_menus( array('primary-menu' => 'Above Title','secondary-menu' => 'Below Title',) );
}
}
Now go to the section where your navigation menu items would appear. Simply add
1 2 3 4 5
wp_nav_menu();
or
wp_nav_menu( array('menu' => 'primary-menu' ));
to activate custom menu option. Now go to Appearance – > Menus and create a menu by typing a name. It can be any name of your choice.
Now assign created pages to the menu and go to your site’s frontend to see your custom menu items.
Above example shows I’ve selected 2 pages (with tick mark) and left home page so that it doesn’t appear in menu. You can select any page or category item to appear within a menu.
Copyright © 2010 PHP code. net. All Rights Reserved. Designed By: Web Design Company