Posted on Leave a comment

How to create custom widget Area in the admin Widgets page?

To create custom widget area we will need functions.php file (should be in the root directory of the theme) to add some custom code. We use wordpress filter “widgets_init”.

<?php
function register_my_sidebar()
{

  $args = array(
	'name'          => __( 'Footer 1', 'theme_text_domain' ),
	'id'            => 'footer-widget-1',
	'description'   => '',
        'class'         => '',
	'before_widget' => '<li id="%1$s" class="widget %2$s">',
	'after_widget'  => '</li>',
	'before_title'  => '<h2 class="widgettitle">',
	'after_title'   => '</h2>' ); 
    register_sidebar( $args );
}

add_filter('widgets_init', 'register_my_sidebar');


?>

You can copy paste this code in your functions.php file to see results.

Result will look like in the screenshot below ( Inside the admin panel > Appearance > Widgets ):

Screenshot_1

Posted on Leave a comment

Wordpess: How to display the WCK Plugin’s Custom fields in the page or post?

$meta =  get_post_meta(get_the_ID(), 'name_of_meta', true);  // name_of_meta is the name of meta box linked the the current post ID.
$meta = $meta[0];

// Now in $meta variable we have all fields available in this meta box which we added in the WCK custom fields section.

// We can access fields as shown below:

echo $meta['field1'];

 

Posted on Leave a comment

WordPress: How to display navigation menu in your custom theme?

<?php

$defaults = array(
	'theme_location'  => 'primary',
	'menu'            => '',  // name of the menu you created in the menus
	'container'       => '',
	'container_class' => '',
	'container_id'    => '',
	'menu_class'      => '',
	'menu_id'         => '',
	'echo'            => true,
	'fallback_cb'     => 'wp_page_menu',
	'before'          => '',
	'after'           => '',
	'link_before'     => '',
	'link_after'      => '',
	'items_wrap'      => '<ul id="%1$s" class="%2$s nav navbar-nav right_navbar">%3$s</ul>',
	'depth'           => 0,
	'walker'          => ''
);

 wp_nav_menu( $defaults );

?>