-
Author
-
September 27, 2015 at 19:34 #79688lopregParticipant
Please, I need help on how to create a drop down jump menu of categories on my site. I need to place it on my site’s header below the main menu.
September 28, 2015 at 15:01 #79741sharmstrModeratorDo a google search for code that will produce the menu you want. Then you can inject it into the pages below the menu using this code in your child theme’s functions.php file
COPY CODEadd_action('kleo_before_content','my_header_menu'); function my_header_menu() { // yourcode here }
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionThis support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com
September 29, 2015 at 05:45 #79817lopregParticipantAfter doing a google search, I came across this page http://codex.wordpress.org/Template_Tags/wp_dropdown_categories.
The issue I am having now is how to properly add the code to the function without breaking the site. Please, pardon me, am not that great with php.
Here is what I have at the moment which breaks on line 25;
<?php
/**
* @package WordPress
* @subpackage Kleo
* @author SeventhQueen <themesupport@seventhqueen.com>
* @since Kleo 1.0
*//**
* Kleo Child Theme Functions
* Add custom code below
*/
add_action( ‘wp_enqueue_scripts’, ‘load_buddypress_js’ );
function load_buddypress_js () {
if (bp_is_group() || is_page( ‘activity’ )) {
wp_enqueue_script(‘buddypress_query’,plugins_url() . ‘/buddypress/bp-core/js/jquery-query.min.js’,array(“jquery”));
wp_enqueue_script(‘buddypress_members’,plugins_url() . ‘/buddypress/bp-core/js/widget-members.min.js’,array(“jquery”));
wp_enqueue_script(‘buddypress_cookie’,plugins_url() . ‘/buddypress/bp-core/js/jquery-cookie.min.js’,array(“jquery”));
wp_enqueue_script(‘buddypress_scroll’, plugins_url() . ‘/buddypress/bp-core/js/jquery-scroll-to.min.js’, array(“jquery”));
wp_enqueue_script(‘buddypress_js’,get_template_directory_uri() . ‘/buddypress/js/buddypress.min.js’,array(“jquery”));
}
}
add_action(‘kleo_before_content’,’my_header_menu’);
function my_header_menu() {
<li id=”categories”>
<h2><?php _e( ‘Posts by Category’ ); ?></h2>
<form id=”category-select” class=”category-select” action=”<?php echo esc_url( home_url( ‘/’ ) ); ?>” method=”get”><?php
$args = array(
‘show_option_none’ => __( ‘Select category’ ),
‘show_count’ => 1,
‘orderby’ => ‘name’,
‘echo’ => 0,
);
?><?php $select = wp_dropdown_categories( $args ); ?>
<?php $replace = “<select$1 onchange=’return this.form.submit()’>”; ?>
<?php $select = preg_replace( ‘#<select([^>]*)>#’, $replace, $select ); ?><?php echo $select; ?>
<noscript>
<input type=”submit” value=”View” />
</noscript></form>
}
September 29, 2015 at 13:54 #79837sharmstrModeratorCOPY CODEfunction my_header_menu() { ?> <li id="categories"> <h2><?php _e( 'Posts by Category' ); ?></h2> <form id="category-select" class="category-select" action="<?php echo esc_url( home_url( '/' ) ); ?>" method="get"> <?php $args = array( 'show_option_none' => __( 'Select category' ), 'show_count' => 1, 'orderby' => 'name', 'echo' => 0, ); ?> <?php $select = wp_dropdown_categories( $args ); ?> <?php $replace = "<select$1 onchange='return this.form.submit()'>"; ?> <?php $select = preg_replace( '#<select([^>]*)>#', $replace, $select ); ?> <?php echo $select; ?> <noscript> <input type="submit" value="View" /> </noscript> </form> </li> <?php }
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionThis support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com
September 29, 2015 at 14:22 #79843lopregParticipantThanks a lot for the response. I tried the code but the form didn’t display anywhere on the site.
If I add only the form code without the function my_header_menu() code, the form display but not positioned in the desired location. Kindly review the code you supplied me. Thanks again.September 29, 2015 at 14:29 #79846sharmstrModeratorDid you delete the add action code? You shouldnt have. I was merely fixing the bad function code you had.
Keep in mind, this is not supported. I was only showing you how to inject code below the menu. You’ll have to find code and css to make it work and look the way you want.
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionThis support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com
September 29, 2015 at 14:38 #79847sharmstrModeratorAnd actually, it would be right after the title section. If you want it between the menu and the title section, you’ll have to copy /kleo/page-parts/general-header-section.php to your child theme and put this at the bottom
COPY CODE<li id="categories"> <h2><?php _e( 'Posts by Category' ); ?></h2> <form id="category-select" class="category-select" action="<?php echo esc_url( home_url( '/' ) ); ?>" method="get"> <?php $args = array( 'show_option_none' => __( 'Select category' ), 'show_count' => 1, 'orderby' => 'name', 'echo' => 0, ); ?> <?php $select = wp_dropdown_categories( $args ); ?> <?php $replace = "<select$1 onchange='return this.form.submit()'>"; ?> <?php $select = preg_replace( '#<select([^>]*)>#', $replace, $select ); ?> <?php echo $select; ?> <noscript> <input type="submit" value="View" /> </noscript> </form> </li>
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionThis support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com
September 29, 2015 at 15:17 #79849lopregParticipantHi,
Sorry to bother you. I didn’t actually delete the add action code, I only temporarily tested the form code alone to be sure nothing is wrong with it. Your code actually fixed my bad function code but my form didn’t get to display anywhere on the page. I have also moved the general-header-section.php file to my child’s theme like you suggested but adding the code to the bottom did not still display the form anywhere.
I suspect something is preventing it from appearing below the menu because when I placed the form code alone in the function.php, it appeared at the top most of the site.Please, don’t be upset. I know this is not supported, I am only asking for your help as I couldn’t get help elsewhere.
Thanks for your anticipated kind response.September 29, 2015 at 15:21 #79850sharmstrModeratorWhen you copied the file, did you retain the directory path?
/kleo-child/page-parts/general-header-section.php
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionThis support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com
-
AuthorPosts
The forum ‘KLEO’ is closed to new topics and replies.