Tag Info

New answers tagged

4

Got a working function, but not sure if it is the best solution. I used a custom walker: class Custom_Walker_Nav_Menu extends Walker_Nav_Menu { function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) { global $wp_query; $indent = ( $depth ) ? str_repeat( "\t", $depth ) : ''; $classes = empty( $item->classes ) ? ...


7

There even is a way to make this possible with CSS alone. This has some limitations, but I still thought it might be an interesting approach: Limitations You need to hardcode the width of the dropdown Browser-Support. You basically need CSS3 selectors. But everything from IE8 up should work, although I haven't tested this. This is more of a ...


6

You can use wp_nav_menu_items filter. It accepts menu output and arguments which hold menu attributes, like menu slug, container, etc. add_filter('wp_nav_menu_items', 'wpse_180221_nav_menu_items', 20, 2); function wpse_180221_nav_menu_items($items, $args) { if ($args->menu != 'my-menu-slug') { return $items; } // extract all ...


0

From first view this seems to be tough job, but actually even I having small skills of php could solve this problem just adding following code to my custom walker class: if ( $depth == 1 ) { // remove this statement if depth check is not required if (wp_get_nav_menu_object($item->title)) {// checking if item name matches to menu name $item_output ...


0

I dont think you need a plugin. You just need to register your custom menu in your theme funtion.php file. Something like : function register_vertical_fixed_menu() { register_nav_menu('vertical-menu',_(Vertical Menu)); } add_action('init', 'register_vertical_fixed_menu'); Your theme is now ready for displaying the menu See more about adding custom ...


0

You can just add a custom function to the nav_menu_item_id hook that does something like this: function custom_nav_menu_item_id($menu_id, $item, $args, $depth) { if ($item) { switch ($item->object) { case "page": // If the menu item's object is a page, // retrieve it and return its name. ...


0

It is sometimes irritating that some build-in functions don't have appropriate filters to modify their output. get_boundary_post() is one of those build-in functions. Unfortunately it does not get posts according to post type, only taxonomy. You can still however make use of this function to get the first and last post. It does support the $in_same_term ...


0

I know this is a long time after the question, but I had the same issue as mentioned in the question. I found no suitable solution in tutorials or on any stackexchange and in the end gave up and wrote my own code for it. I've since published it as a plugin: Bop Search Box Item Type For Nav Menus Crucially, this adds the search box as a menu item option ...


0

Please try this , <form name="searchBox" action="<?php echo get_bloginfo('url'); ?>" class="search-form" method="get" role="search" > <input type="text" name="s" class="searchBox" placeholder="search" value="<?= $_GET['s'] ?>" required /> <button type="submit" class="searchBtn" >search</button> ...


1

I'm new to WordPress myself, but I think answering questions is a good way to learn. There may be a way to use hooks, but I couldn't figure that out, so went ahead with directly editing header.php. I tried the following: From Appearance, Menus, I added a new menu and named it Vert_Menu_test I chose to add the menu to the top left corner of my test site: ...


0

You need/want a Favicon. First choose an icon image (32x32 or 16x16 its ok), upload this to public_html\yoursite\ Go to your Dashboard Wordpress, now go to Appearance > Editor > header.php Put this code after the <title> label. <link rel="shortcut icon" href="http://www.yoursite.com/favicon.ico" type="image/x-icon" /> Only edit the URL ...


1

I believe your question is about creating a "favicon". This is a small image that is served up by your site and appears on each browser tab you may have opened. The WordPress Codex lists a convenient step-by-step on creating a favicon. http://codex.wordpress.org/Creating_a_Favicon Creating a Favicon A favicon can be created using any graphics/image ...


1

If you want to get the corresponding post ID's from a given menu id, try: $menu_id = 'mymenu'; $items = wp_get_nav_menu_items( $menu_id ); $ids = ( $items ) ? wp_list_pluck( $items , 'object_id' ) : array(); where you have to modify the $menu_id to your needs.


0

Soooo, I have tried the solution with javascript. It works without problems. For debug test: <script> $(function() { alert($('.menu-item').attr('id')); }); </script> It gives me the id from every element in the nav out as alert. I extract now the number at the end and have then the menu-item-id. thanks for all answers, ...


0

html mark up for navigation will look like this <ul id="menu-res" class="main-menu"><li id="menu-item-72" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-72"><a href="#home">Home</a></li> <li id="menu-item-238" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-238"><a ...



Top 50 recent answers are included