Home › Forums › Free Themes › Photo Perfect › Right Category Drop Down Menu
Tagged: categories, dropdown menu
How can I make a drop down below Category Menu on the website.. I did the one on the Menu drop down .but cant seem to do it on the right side drop down menu. in categories?
Hello Del,
First make a Child Theme and activate it before you go making the following changes. You will have two new files functions.php and style.css .
After you are done with Child Theme set up copy and paste the following piece of PHP code in your functions.php file.
function photo_perfect_add_category_navigation(){
$show_category_dropdown = photo_perfect_get_option( 'show_category_dropdown' );
if ( true !== $show_category_dropdown ) {
return;
}
?>
<div id="category-menu" class="clear-fix header-navigation">
<div class="container">
<button class="nav-list-btn"><i class="fa fa-list"></i><span><?php _e( 'Category', 'photo-perfect' ); ?></span></button>
<div class="category-list-wrapper">
<ul>
<?php wp_list_categories( 'title_li=&depth=2' ); ?>
</ul>
</div><!-- .category-list-wrapper -->
</div><!-- .container -->
</div><!-- #category-menu -->
<?php
}
Now put following line of CSS code in style.css file.
.header-navigation ul .toggled-on {
display: block;
}
button, input[type="button"]:focus, input[type="reset"]:focus, input[type="submit"]:focus, .comment-reply-link:focus{
outline: none !important;
}
This should do the trick appearing the sub-menu categories as dropdown like the one in main Menu.
Parse error: syntax error, unexpected ‘if’ (T_IF) in /home1/xxxxxx/public_html/xxxxxxx.com/wp-content/themes/child-theme/functions.php on line 18
errors came up
Your entire functions.php code with above custom code should be look like this.
<?php
/**
* Child Theme functions and definitions
*
*/
/**
* Loading Parent theme stylesheet
*
*/
add_action( 'wp_enqueue_scripts', 'photoperfect_child_enqueue_styles' );
function photoperfect_child_enqueue_styles() {
wp_enqueue_style( 'photoperfect-parent-style', get_template_directory_uri() . '/style.css' );
}
function photo_perfect_add_category_navigation(){
$show_category_dropdown = photo_perfect_get_option( 'show_category_dropdown' );
if ( true !== $show_category_dropdown ) {
return;
}
?>
<div id="category-menu" class="clear-fix header-navigation">
<div class="container">
<button class="nav-list-btn"><i class="fa fa-list"></i><span><?php _e( 'Category', 'photo-perfect' ); ?></span></button>
<div class="category-list-wrapper">
<ul>
<?php wp_list_categories( 'title_li=&depth=2' ); ?>
</ul>
</div><!-- .category-list-wrapper -->
</div><!-- .container -->
</div><!-- #category-menu -->
<?php
}