register and place menu, sidebar, custom post etc

Menu

First register the navigation menu in functions.php file. To do this we have to write the following code inside functions.php file:

//top navigation menu

load_theme_textdomain('komola', get_template_directory_uri().'/langulages');
register_nav_menu('komola-main-menu', __('Komola main menu', 'komola'));

In the front end php file (location of actual menu):

// find out the <ul> of the HTML coding like below:
<ul class="nav navbar-nav navbar-right text-uppercase">
	<li><a href="index.html">home</a></li>
	<li class="active"><a href="#">our service</a></li>
	<li><a href="pricing.html">pricing</a></li>
	<li><a href="blog.html">blog</a></li>
	<li><a href="contact.html">contact</a></li>
</ul>

// replace the <ul> with the following code. Put the class of ul as menu_class as following

<?php 
    wp_nav_menu(array(
         "theme_location" => "komola-main-menu",
         "menu_class" => "nav navbar-nav navbar-right text-uppercase"
    )); 
?>

Sidebar


Declare a function in functions.php and add that in a ‘widgets_init’ hook

//register sidebar
function sidebarRegister(){
	register_sidebar(array(
		'name' => __('Right Sidebar', 'capsule'),
		'description' => __('Add your sidebar widgets here', 'capsule'),
		'id' => 'right-sidebar', 
		'before_widget' =>
		'after_widget' =>
		'before_title' =>
		'after_title' =>
	));
}

add_action('widgets_init', 'sidebarRegister');

Then, in the page where we want to show the side bars, we need to call the sidebar function.

<?php dynamic_sidebar("right-sidebar"); ?>

 

Custom Post:


In the functions.php file add the following code to register a custom post type.

register_post_type('about', array(
	'labels' => array(
		'name' => 'About Us section',
		'add_new_item' => 'add new text to about us section'
	),
	'icon' => 'el-resize-horizontal',
	'public' => true,
	'supports' => array('thumbnail')
	));

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *