• Sweet Solutions
  • Home
  • About
  • Services
    • Terms of Service
    • Frequently Asked Questions
  • Design Packages
    • Get a Quick Quote
  • Get Started
  • Portfolio
    • Featured Projects
  • Testimonials
  • Blog
  • Contact

Sweet Solutions

Web design with flair

Archives for how to do it

PHP 5 is dead . . . Long live PHP 7

Leave a Comment

Work deskPHP 5 is dead. It died on December 31, 2018. At the end of this month, security patches and updates will no longer be available. Hosting services everywhere are requesting that everyone update the PHP used on their account to PHP 7 . . . and the clock is ticking.

PHP 7 is the latest version of the popular programming, and it’s significantly different from PHP 5. Here’s everything you need to know about PHP 7. The good news is, PHP 7 is faster, more secure, and uses less server resources than previous versions. The bad news is, there is a chance you will need to make changes in your code as some WordPress themes and plugins being used might not be compatible with PHP 7.

Bummer. Nobody wants to do an update if it might crash their site.

There are all sorts of places on the Internet that give instructions on how to switch to PHP 7 safely. WP Engine offers excellent information, instructions, and one-on-one support if you need it.

My site, and those I design, are relatively small, blogs mostly, created in WordPress and Genesis—who both keep their code clean and up-to-date—and I only use WordPress plugins that can be swapped out if one or another has an issue.

Here’s what I did to switch myself and clients over to PHP 7 with as few issues as possible:

  1. Updated anything and everything calling for updates.
  2. Installed PHP Compatibility Checker by WP Engine. Plugin is a freebie in the WordPress Admin area under Plugins.
    • Scanned my website for compatibility issues.
    • Reviewed the report it generated and created a screenshot of the results. There were some warnings, and I figured the screenshot would help later. If anything was wonky after the update, I would know where to look first.
    • Deactivated and deleted the PHP Compatibility Checker plugin.
  3. Made a full backup of the website. This was important. If the site crashed after the update, there was still time to revert back to PHP 5.
  4. Logged into the hosting service control panel and switched to PHP 7.
  5. Refreshed the website and checked to see if all was well.
  6. Breathed a sigh of relief.

Although upgrading from PHP 5 to PHP 7 involves carefully checking for incompatibilities, both in your code and in any extras your code depends upon, the benefits make the effort worthwhile. Hire a pro if you don’t want to chance doing it yourself.

After this month, you have no choice. Long live PHP 7.

Filed under how to do it, PHP

My Custom Taxonomy for Recipe Tags

Leave a Comment

Tag cloud

Let’s say you have a blog, and on that blog you post recipes. Each time you post a recipe you file it under one or more tags—salads, soups, desserts, chicken, fish, Italian, Mexican, pasta, or another tag that’s appropriate.

Whenever you post anything on your blog, whether it’s a recipe or not, you tag it. Tags are a useful way of grouping related posts together. Readers can quickly tell what the post is about, or they can click on the tag to see a list of related posts they might be interested in reading.

Now let’s say, you want only the tags for your recipes to appear in your sidebar. The default tag cloud in the WordPress widget area will pick up tags for all of your posts, not just for recipes.

What you need is a custom taxonomy especially for “recipes.”

Here’s how to do it

IMPORTANT: In all cases, if you change the name of the taxonomy from recipes to something else, be sure to change every instance of “recipes” in the code.

  1. Create the custom taxonomy by adding the following code to your functions.php:
    /** Register custom taxonomy */
    add_action( 'init', 'register_taxonomy_recipes' );
    function register_taxonomy_recipes() {
        $labels = array(
        'name' => _x( 'Recipes', 'recipes' ),
        'singular_name' => _x( 'Recipes', 'recipes' ),
        'search_items' => _x( 'Search Recipes', 'recipes' ),
        'popular_items' => _x( 'Popular Recipes', 'recipes' ),
        'all_items' => _x( 'All Recipes', 'recipes' ),
        'parent_item' => _x( 'Parent Recipes', 'recipes' ),
        'parent_item_colon' => _x( 'Parent Recipes:', 'recipes' ),
        'edit_item' => _x( 'Edit Recipes', 'recipes' ),
        'update_item' => _x( 'Update Recipes', 'recipes' ),
        'add_new_item' => _x( 'Add New Recipes', 'recipes' ),
        'new_item_name' => _x( 'New Recipes', 'recipes' ),
        'separate_items_with_commas' => _x( 'Separate recipes with commas', 'recipes' ),
        'add_or_remove_items' => _x( 'Add or remove recipes', 'recipes' ),
        'choose_from_most_used' => _x( 'Choose from most used recipes', 'recipes' ),
        'menu_name' => _x( 'Recipes', 'recipes' ),
        );
        $args = array(
        'labels' => $labels,
        'public' => true,
        'show_in_nav_menus' => true,
        'show_ui' => true,
        'show_tagcloud' => true,
        'show_admin_column' => true,
        'hierarchical' => true,
        'rewrite' => true,
        'query_var' => true
        );
        register_taxonomy( 'recipes', array('post'), $args );
    }
  2. To have the new custom taxonomy appear at the bottom of your posts, add the following code to your functions.php:
    /** Customize post meta function */
    add_filter( 'genesis_post_meta', 'post_meta_filter' );
    function post_meta_filter($post_meta) {
        if ( !is_page() ) {
        $post_meta = 'Filed under how to do it, taxonomies';
        return $post_meta;
        }
    }
  3. The default number of tags in a tag cloud is 45. If you have more than 45 tags and want all of the tags to appear, add the following code to functions.php:
    /** Change number of tags in tag cloud */
    add_filter( 'widget_tag_cloud_args', 'custom_tag_cloud_widget' );
    function custom_tag_cloud_widget($args) {
        $args['number'] = 0; //adding a 0 will display all tags
        $args['exclude'] = array(); //exclude or include tags by ID
        return $args;
    }
  4. SAVE your updated functions file. Then—and this is important—go to your Dashboard >> Settings >> Permalinks and SAVE.

That’s it. Your new custom taxonomy will be listed in your Dashboard menu on the left under Posts. When you write a new post, you’ll find Tags and Recipes on the right side of the edit screen. To add a tag to the new taxonomy, click Add New Recipes. If the tag you want is already listed, just check the box. On existing recipes, delete tags and create new ones using the new custom taxonomy. If you want to use both tags and the new taxonomy, you’ll have to further customize the meta function.

Any questions, just ask.

Filed under how to do it, taxonomies

My Current-Menu-Item

Leave a Comment

my current-menu-itemI’m not especially fond of breadcrumbs. I have nothing against them personally and have no problem when people choose to use them, but for my own personal websites I prefer to have highlighted menu items indicating where on the website people are. My websites are small, and the hierarchy only goes so deep. Every page points to a menu item. So it makes perfect sense to me that the menu item a page points to should be highlighted in some way when you’re on that page.

On this site I chose to go with something quirky and fun. Not only did I want the text to change from black-to-red, but I wanted a little strawberry to appear above the menu item. It doesn’t matter which page or sub-page or category you go to on my site, the menu item comes up highlighted with red text and that quirky little strawberry.

Adding a current-menu-item class for the primary menu was easy. Mine looks like this:

.nav-primary .current-menu-ancestor a,
.nav-primary .current-page-ancestor a, 
.nav-primary .current_page_item a {
	background: url(images/float.png) top center no-repeat; 
	color: #b90000;
	}

NOTE: My site does not use current-menu-item; instead, it uses current-page-item.

Because the above CSS also added the quirky little strawberry and text color change to the sub-menu items, which I did not want, I had to include the following:

.sub-menu .current-page-ancestor a, 
.sub-menu .menu-item a {
	background: none;
	}

So far, so good. The only thing left were the posts.

Normally, adding classes to the CSS or code to functions.php does the trick. This time, however, no matter what I tried, I could not get posts to point to the correct menu item.

Finally, I found a way. Here’s what I did you can try:

  1. Install the Genesis Simple Hooks plugin by Nathan Rice.
  2. Activate the plugin.
  3. Go to Genesis >> Simple Hooks (on your Dashboard menu) and add something like this to the wp_head hook:

    <?php if ( is_single() && in_category( 'blog' ) ) { ?>
        <style type="text/css">
            .nav-primary #menu-item-1306 {
                background: url(https://yourwebsite.com/wp-content/uploads/image.png) top center no-repeat;
            }
            .nav-primary #menu-item-1306 a {
                color: #b90000;
            }
        </style>
    <?php }

  4. Change the code in red to (1) the category your post is in, (2) the ID for the menu item you want to highlight (view source code to find out what it is), and (3) the image file you want to use for the background.
  5. Check the little box to execute PHP on the hook
  6. Save. That’s it!

There are two categories on this website that feature posts. Here’s what my full code in Genesis Simple Hooks looks like.

Filed under how to do it, menus

strawberries

What I Write About

added flair favicons Google doodles hosting how to do it Inspiration for the Spirit marketing menus mobile responsiveness my other life Our Empty Nest Patpourri PHP Sweet Solutions taxonomies the cloud UX web design WordPress
Archives

Tweets by @sweetsolutions1

Location

Patricia Petro
Sweet Solutions
Findlay, OH USA

Email: patpetro@msn.com
somesweetsolutions.com

Calendar

We only take on a limited number of projects
and are usually booked 2-3 weeks out
at any given time.
Contact us to get in queue.

Contact Form

Let’s Connect

  • Facebook
  • LinkedIn
  • Twitter

Sweet Solutions ESTd 2002 • Copyright © 2023 Patricia Petro • Created with ♥ in WordPress and Genesis.

PRIVACY POLICY • LOGIN

strawberries and cream