Disable Changing The WordPress Theme

Updated: in Wordpress

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 user to be admin to change theme or plugins.

You need a way of blocking access to the themes area. You can block access to the themes screen to anyone apart from the super admin user. Below is the snippet to check the user ID and remove the themes item from the menu.
Continue reading »

Add New Menu Items To WordPress Admin

Updated: in Wordpress

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 to put links to the theme settings under the appearance tab, some people prefer to create a brand new menu item in the WordPress admin area just for your theme.

If you are creating a theme I think it's better to add your link to your theme settings page under your appearance tag. This is because a theme is used for the appearance of your site and all the settings should be under the appearance tab.
Continue reading »

WordPress Theme CSS Starter

Updated: in Wordpress

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 the title, the date for the post, the main content and then the comments section.

The thing that makes each WordPress theme different is the CSS, this will decide how the theme looks and feels. Because wordpress has functions to add in CSS to your theme you need to know what these CSS classes are so you can style your theme. In this article we are going to a have a look at the CSS classes you will find inside a WordPress theme.

You should be able to take the CSS in this article and use it as a starting point for your next WordPress theme.
Continue reading »

Add Search Form To A WordPress Menu

Updated: in Wordpress

Wordpress

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 find what they are looking for then they can use your search box.
Continue reading »

How To Register Menus In WordPress

Updated: 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 can create a menu for all your categories and display this at the top of your page.
Continue reading »

Add a WordPress Menu To Your WordPress Toolbar

Updated: in Wordpress

Wordpress Admin Bar
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 menu items by using the function wp_get_nav_menu_items().
Continue reading »

Use jQuery To Highlight Active Menu Item

Updated: in jQuery

If you are using menus on your web designs it's a common web design technique to highlight the current page that you are on to show you where you are on the site.

This technique is normally done by adding a CSS class to the menu item to highlight it differently to the other menu items.

If your using a WordPress site then you are most likely using the WordPress function wp_nav_menu() to display the menu items. In wordpress this function will automatically add a CSS class of current_page_item to the current page.
Continue reading »

Remove Links From WordPress Admin Menu

Updated: in Wordpress

Since WordPress 3.1 they have made it very easy to remove any unwanted links from the admin menu bar.

Wordpress link menu

Most people don't want the Links menu item to be displayed so by adding the following code to your functions.php page you can remove the links menu item.

Continue reading »