Display WooCommerce category description and custom category titles

WooCommerce category description and custom title

David Nash woocommerce, wordpress 0 Comments

The WooCommerce category description is a good way to increase usability and improve SEO on your site. We can also show a custom category title which is a little more descriptive. To do this, it’s good practise to start with something easy, get that working, and then build from there. Show the WooCommerce category description In the child theme, if it doesn’t already exist, create a woocommerce/ directory. Copy the template file from wp-content/plugins/woocommerce/templates/archive-product.php  to wp-content/themes/[your-child-theme]/woocommerce/archive-product.php. Now we can edit that without changing any plugin files directly (which could get replaced on the next update). In WooCommerce 2.0.0+, towards the top of …

How to create a select element option (drop-down) menu in the WordPress Theme Customizer

David Nash css, php, wordpress 1 Comment

I’m working on a project that requires the same basic theme for two companies that are both under the same group. The only real difference is the logo and theme colours. Instead of creating two separate themes and having to maintain them separately I used WordPress “customize_register” action in the theme’s functions.php. The official docs are here and very long and confusing. https://codex.wordpress.org/Theme_Customization_API WordPress provides some basic types like a text field, image upload and colour picker, but no select menu: https://codex.wordpress.org/Class_Reference/WP_Customize_Manager/add_control Here’s the code I’m using to create a select element with two options (in the theme’s functions.php file): …

WordPress: show sticky posts, then show all other posts in one loop

David Nash php, wordpress 1 Comment

This is something that’s driven me a little insane for a while. WordPress posts can be marked “sticky”, which is awesome. But if you’re not using it on the home page it just doesn’t work. In the past I’ve given up and resorted to doing two “The Loop”s, one with just stickies and one without. But there’s an easier way. In your themes functions.php, do this:

There’s nothing else to chage – the filter just steps in and takes care of it! Based on this answer http://wordpress.stackexchange.com/a/87788, which I only needed to minimally modify to get working. This uses …

Disable WordPress Theme “Update Available” Notification

David Nash wordpress 17 Comments

I’ve been customising a theme that had a new version, getting the message “There is a new version of … available”. I didn’t want the end-user to update the theme, because I’d customised it so heavily. I know that any updates are going to need to be done by a WordPress theme developer. After a while of searching through code, looking for add_action and add_filter hooks, and even delving into the database, I realised I could just edit the theme’s style.css and remove the “Version:” line from the WordPress specific CSS header right at the top. And the notification (and …

WordPress upgrade “Briefly unavailable for scheduled maintenance. Check back in a minute.”

David Nash wordpress 2 Comments

I just updated my WordPress installation from 3.2 to 3.3. The upgrade was running but then the page directed to this message:

The front page and wp-admin both showed this unstyled message. After a quick search I found that simply deleting the .maintenance file via FTP will remove this. Perhaps it’s a bug in this version, perhaps something went wrong. But after deleting that file everything seems to be working well. And I must say I like the design tweaks in WordPress 3.3.

WordPress Theme Development Quick Start

David Nash css, html, php, wordpress 0 Comments

I’ve created plenty of WordPress themes based on designs from clients. This is the process I usually follow. 1. Create a static HTML and CSS template. I create index.html and style.css. 2. Install WordPress 3. In the WordPress folder wp-content/themes/ I create a folder with the name of my new theme. 4. Copy my static HTML to the new theme folder. 5. Modify style.css, add the WordPress stylesheet header: /* Theme Name: THEME_NAME Theme URI: YOUR_WEBSITE Description: THEME_DESC Version: 0.1 Author: YOUR_NAME */ 6. Rename index.html to index.php. Open index.php and replace the reference to style.css with < ?php bloginfo( ...

WordPress: Limit Archives to Single Category

David Nash mysql, php, wordpress 9 Comments

Late yesterday afternoon a client asked if I could look at a business’s WordPress installation. They had posts in several categories but only wanted to show the “Latest News” posts in the archives. WordPress is designed around blog posts, whereas I find that many business or company sites are designed around pages (eg About Us, Contact Us) – and don’t use WordPress’ powerful blogging tools on the front page. My site is an example – the content on the home page doesn’t change that much. This means that many of the solutions are also geared around blog-post design. While searching …

New WordPress theme for my site

David Nash css, wordpress 3 Comments

I’ve been meaning to update my website’s design and layout for a long time. My site is based on WordPress and the theme I’d been using previously was a little too sterile. I wanted something that was more of a portfolio site and yet could still accommodate a blog. After sporadic searches through the free WordPress themes on offer, I decided none of them quite did what I wanted, so I designed my own. I wanted to keep it minimal while making use of emerging web technologies like HTML5, CSS3; and I wanted the site to look just as good …

Duplicate WordPress site for local development and testing environment

David Nash mysql, wordpress 4 Comments

Update: This is not the best way to do this – use Search and Replace for WordPress databases instead. 1. Download all files from eg http://example.com, upload to eg http://localhost/example/. 2. Export mysql database from example.com 3. Create a local mysql database with the same user, password and database name. These can be found in wp-config.php 4. Import the database into your new local account 5. Log in to the database, and do: update wp_options set option_value=’http://localhost/example/’ where option_id=1 You’ll now be able to log in at http://localhost/example/wp-admin, using the same username and password as http://example.com/wp-admin. 5. In WordPress, click ‘Settings’ …

Quickly replace the header image in the default WordPress 2.7 Kubrick theme

David Nash General, wordpress 4 Comments

I was asked to do some quick mods to client’s WordPress blog. He wanted to replace the banner image. He’s using WordPress 2.7 and has the default Kubrick theme. This isn’t as easy as you would think as it’s generated by PHP so that the colours can be dynamically set. Here’s what I did: Download wp-content/themes/default/images/kubrickheader.jpg Modify it, save and upload as wp-content/themes/default/images/kubrickheader_NEW.jpg Edit wp-content/themes/default/header.php. On line 42 you should see <div id=”headerimg”> Modify this so it reads: <div id=”headerimg” style=”background: url(<?php bloginfo(‘stylesheet_directory’); ?>/images/kubrickheader_NEW.jpg) no-repeat -1px 0″> Upload header.php and it should now be using your new header. I used …