Custom Post Type for a Menu

August 29, 2014 (10 years ago)
PHP, Plugins

I created this simple plugin for a restaurant to post their menu online.

Here’s the plugin file (put in plugins directory).

It includes categories (for menu sections), and several parameters for each item.

Now here’s the menu category display page. Create a page named “archive-grille_menu.php” and upload to your theme directory. Replace the loop with this code:

(I listed the categories in two columns.)

 Next is the display page for each category:

Remember to change the divs and styling to match your page layout.

 You can see this plugin in action at: http://paradisegrille.net.

 

 

Make a Table Mobile Responsive

July 31, 2014 (10 years ago)
CSS, Responsive Design

If you’re using display:table, rather than a real table, for layout, this CSS will make it mobile responsive:

 

Social Share Buttons Without a Plugin

July 1, 2014 (10 years ago)
PHP, WordPress

Most sharing plugins are too loaded with options, and tend to slow down my sites.

I wrote this simple script to counter that.

Create this file and name it “sharebuttons.php”. Upload it to your theme directory.

You will also need to create your images, and style the div as you like.

 Then, to add the div to pages or posts, just put this in your template file, immediately following (or just before) the_content() — or wherever you want the buttons to appear:

Custom Admin Page

July 1, 2014 (10 years ago)
Functions, PHP, WordPress

I use these for those occasions when I need to store specialized information in non-WordPress tables. (Such as orders in a custom shopping cart I built.)

It’s also handy for adding informational or instructional pages to the Dashboard.

This adds the page to the WP admin menu (put in your functions.php file):

 The page itself ( lt_orders.php ) resides in the theme folder, and is a simple PHP page, with any functionality you like. It doesn’t need any header or footer calls because it is rendered inside the admin.

Custom Logo on Login Page

July 1, 2014 (10 years ago)
Functions, WordPress

It’s a nice touch to customize for the client. We can also change the link to the site home page, and the title to the site name.

Put this in your functions.php file.

Check the path and name for your image, and make sure it’s no larger than 80px x 80px.

This is my collection of WordPress, CSS, JS and PHP code

July 1, 2014 (10 years ago)
General

This is a personal collection of snippets I use on client sites. Some are original, some highly modified or cobbled together from other sources, and some copied (only from open sources such as this.)

I generally prefer not to use plugins for simple features and functions, especially if my clients don’t need options, which is quite often the case.

Free support for these snippets is probably not an option for your unique applications, due to my work load, but it never hurts to ask.

Copy, share and code on!

Mobile Nav without Javascript

June 26, 2014 (10 years ago)
CSS, Responsive Design, WordPress

I wasn’t happy with the JS (or jQuery) mobile menu solutions I had been using. They always seemed to have some sort of a glitch.

My solution was to build a mobile nav which gets the menu items  with wp_get_nav_menu_items() and then display them as a select drop-down. A little bit of CSS styling on the select box, and voila! A nav menu that works perfectly every time!

Here’s the navigation code:

 And here’s the CSS:

 

 

Front End Login Form

June 20, 2014 (10 years ago)
Functions, PHP, WordPress

So many times clients (and their members) want to login on the front end. Simple to add this in the header, or sidebar. Style as you wish.

Put this in your header template (or anywhere else you want the form to appear.)

 

Add a Custom Avatar

June 20, 2014 (10 years ago)
Functions, WordPress

So the client has a membership site, and wants to have a custom default avatar branded to their site, to replace the boring Mystery Man, or other strange concoctions:

Put this code in your functions.php file.

 Then create your image and upload the file to wp-content/themes/yourtheme/images/avatar.jpg (you can name it anything you want).

Remove Admin Items for Users

June 20, 2014 (10 years ago)
Functions, WordPress

This function allows you to hide critical admin pages from non-admin users. They will still be able to access the pages if they know the URL, but they will not appear in the admin menu.

 

« Previous - Next »