I have limited space for horizontal category navigation bar on top of my theme and I need to limit number of categories shown on this bar and tell WordPress put "More.." as a drop down menu link at the end of the list to let users hover their mouse cursors on that to see other categories as shown in screenshot.
How can I do that?
Depends on what function you're using to format the navigation menu. It's probably wp_list_categories() which might not be the best choice in your case. As #Andre mentioned in his answer, you might want to go with navigation menus available since WordPress 3, but if you need to stick to categories, try get_categories() which will return the categories in a non-formatted way. This will enable you to loop through them in any way that you want, include a counter to limit the general output, and then loop through the rest under the More submenu.
Reference: get_categories
I guess you are using wordpress version 3+.
This is probably not the cleanest way but should work:
Register a custom menu to your template. Watch the 'depth' parameter (because you want the second level)
Go to 'Appearance - Menus'
Create a Custom Menu
Create a 'Custom Link' called 'More...'
add the 'More...' Link with the other categories as sub-categories to the menu.
write your CSS code to only display the second level on hover.
However, I'm not sure if you want the 'More..' menu item to be a linkpage/category. All of that is possible, just add the category/page instead of the 'Custom Link'.
Hope this workaround can solve your problem.
Related
Please help.
I am very new to web development & don't have any computers background. I have created a pincodes database Website pincodes.forinfo.in using WordPress. I want a relationship based dropdown Taxonomies like www.pincode.city.
I have tried many ways from last 6 months but failed. Please help me.
I have custom Taxonomies State, District, City, pincode. I need a taxonomy dropdown, when user clicked on state the second dropdown should show the Districts of that particular state. Like wise when a user clicked on District the third dropdown should show the cities of the particular.
How can it is possible. Please help me.
I want show this dropdown on a WordPress page.
If you are using the latest version of Wordpress then I do not see the reason to be baffled by this, since you will be able to manage this from Appearance->Menu.
Check out my screenshots.
Click on the Screen Options button on the top right corner of the
Menu page. Screen Options
For me, Types is a custom Taxonomy, so I select it. The taxonomies appear on the left now Custom Tax Appears
You can now add the links to your menu and then arrange it so that it becomes a sub-menu of your primary menu.
This is how your menu should look if you want your custom taxonomy to be a sub-item of another menu item.
Sub menu items
You can do this by holding and dragging the item slightly to the right.
You can stack such items one below the other and create endless sub-menus.
I must mention that there are some themes that do not support sub-menus. If you theme doesn't, change it and check again.
Things that you need to do to implement your idea:
Get a good autocomplete plugin - Easyautocomplete (Much better than jQuery UI autocomplete)
Create three input boxes on a custom template page
Use enqueue_script to get your JS files to load with your Wordpress installation
Bind autocomplete to the three input text boxes
Learn how to query your Wordpress installation for your taxonomies
Use a php file to transfer a json file of your taxonomies to the autocomplete function - I would recommend this AJAX plugin
Have conditions in your php file according to which the 2nd field's values are fetched after getting the value of the first field and similarly for the third field
As I said, it's a lot of coding, and if you are really starting out to code this yourself, without much knowledge of PHP or jQuery, it's going to be very difficult. I would suggest you take the help of a developer.
You can even send me the details of logging into your Wordpress installation, if you want me to take a look.
Mail me at arunadaybasu#gmail.com
I want to have a 2 column layout with left bar on my homepage. In the left column, I want a list of categories shown in a tree view for a particular category of the main menu (Main menu has links like Contact Us etc which I do not want in the left tree view). I tried a number of solutions online, but nothing worked. Some of them listed the categories and subcategories, but without any CSS.
Anyone tried solving this?
There's no module that fit your needs, a little development should be done to retrieve the result you are looking for.
You could use the app/design/frontend/base/default/template/catalog/navigation/left.phtml block for this. In that block subcategories from the current category are shown, normally this block only is shown on listpages with subcategories.
You can add this block to the homepage and replace <?php $_categories = $this->getCurrentChildCategories() ?> with custom code which retrieves the categories/menu structure.
I am making a theme. There I want to add extra fields for each menu items ( Appearance > Menus and i.e). In the picture below I want to add some extra form fields ( like radio button, textarea and etc. ) under the field "Description":
Is there any way or tutorial about how can I do this?
I was looking for the same thing.
I found these, all of which work differently.
https://gist.github.com/kucrut/3804376
simple to use and straightforward if you plan to build an elaborate class
(note: with mods this could be used for checkboxes, radio, color pickers, ect)
https://wordpress.org/plugins/sweet-custom-menu/
This worked well, very simple, adds a txt field.
(note: it overrides the whole wordpress_walker class)
http://www.johnmorrisonline.com/how-to-add-a-fully-functional-custom-meta-box-to-wordpress-navigation-menus/
This is very different, it adds an entire mettabox type to the admin menu panel on the LEFT. I elected to use this as I was building my own version of a "mega menu" and wanted to add widgets. With enough work on this item and the one above anything is possible.
Good luck!
It all depends on what you want an extra field for, but sometimes this kind of problem can be resolved by looking at an alternative approach: Add in a shortcode in your menu, giving you the programmatic flexibility to customise your menu item output beyond what is offered by WP.
I need to list a custom menu in wordpress in two stages.
Now I use
wp_nav_menu(array('menu' => 'my menu'))
to list my whole custom menu. But I would like to do something like that:
< list first half of 'my menu' >
display something else, few <div>s etc...
<list the other half of 'my menu' >
So my questions are:
How can I get the exact number of links in my menu?
Is there a way to list menu from the beginning to some point, and then the rest?
What you actually need to use is wp_get_nav_menu_items function, because it returns array of menu items. From that point it is just ordinary php to do what you want.
But, starting from the beginning, are you sure what you need is one menu, maybe better option would be to make two menus? Menus are just arrays of menu items, you can make many of them for different purposes.
I've been fiddling around with Wordpress and I've realised that the links and link categories provide very little functionality.
For example, I want to display all the links in a certain link category in one page, and not any of the other links.
And in the remaining pages I want to display every link except those that have said category.
I can think of a dumb way of doing it, using a simple "Text Widget" and doing the list in HTML, but I was wondering if there was a smarter way. Like a way of being able to select which link categories I want displayed on a "Links" widget. A way to have several such widgets would also be great to divide the links among more than one sidebar.
Thanks in advance.
You can filter links based on the link category, so if you had a category foo you could get all links that were inside foo by using.
<?php wp_list_bookmarks('title_li=&categorize=0&category_name=foo' ); ?>
Foo can also be a varible, so you could figure out which page you were on and filter you list based on the title. In this case if I were on a post or page called bar the output would be all the links in the bar category.
<?php wp_list_bookmarks('title_li=&categorize=0&category_name='.$post->post_title ); ?>