Style A Specific WordPress Menu Item

The following code snippet will allow you to style a specific menu item differently to the other items. When WordPress creates a menu it will use the menus setup in the WordPress admin, this interface gives the user full flexibility of the what items go in the menu and where they are positioned in the theme. WordPress will automatically add ID's and Classes to these menus so that you can

Read more...

Programmatically Add Menu Item

WordPress comes with a default menu system which gives full control to the admin user of the site to change or create as many menu items as you want. To access the menu system in the admin area you just need to go to Appearance -> Menu. From this screen you will be able to see all the menus that currently exist on your WordPress site, you can select any

Read more...

Display Menus When Location Is Assigned

In WordPress the user can create their own menus in the CMS area by just going to Appearance -> Menus. From this page you can then assign these menus to locations in the theme by choosing the theme location for the menu. These theme locations are setup by the theme developer and is done by using the function register_nav_menus(); The register nav menu function can be placed in the functions.php

Read more...

Disable Changing The WordPress Theme

The problem with having a multi-author blog is that you have a lot of users which have access to the admin area of your WordPress site. When they have access to your admin site they have access to change everything about your blog. Yes you can use your access roles and set the different capabilities, but what if you have multiple admin users but you only want the super admin

Read more...

Add New Menu Items To WordPress Admin

If you are a plugin or theme developer then you will get to the stage where you need to add a link to your plugin or theme settings page in your WordPress admin area. The settings page will allow you your user to customise the plugin or theme in anyway they want. There are different ways you can add links to your plugin or theme settings page. Some people like

Read more...

WordPress Theme CSS Starter

Creating a WordPress theme can be lots of work, but the basic HTML for themes are normally quite similar. Each theme will have a way of looping through a list of posts to show the most recent posts, or to display all the posts in a category. The HTML to display a single post inside the single.php will mainly be the same on any theme you have the header for

Read more...

Add Search Form To A WordPress Menu

Wordpress comes with the functionality to create menus in the dashboard area, from here you can select pages or custom custom menu items to make up your menu. Menus are normally going to be display at the top of the page to give the visitor easy access to your main pages. But this top navigation bar is also a good place to have your search box so if people can't

Read more...

How To Register Menus In WordPress

In a previous snippet we learnt How To Register A Sidebar In WordPress in this snippet we are going to learn how we can easily create custom menus and add them anywhere on your WordPress blog. Create A New WordPress Menu WordPress allows you to create your own custom menus from pages or category items. Using your theme settings you can define where certain menus can appear. For example you

Read more...

Add a WordPress Menu To Your WordPress Toolbar

This WordPress snippet will add a WordPress Menu on the WordPress Toolbar. This uses the admin_bar_menu which will run when the admin bar is created. This action calls the function Add_Menu_To_Toolbar. Inside this function we start by grabbing the the WordPress menu "Toolbar Menu" by using the function wp_get_nav_menu_object(). This will return the menu object, from this object we can get the ID for the menu to get all the

Read more...

Get All WordPress Navigation Menus

If you are creating a custom themes options page or a WordPress plugin which needs to get all the WordPress menus in your site. This small function can be very useful, it will return all the WordPress menus on your site in an array so you can process them as you want. This uses the WordPress function get_terms() to get all the nav_menu's on the site.

Read more...

1 2