WordPress IS a CMS and WordPress SHOULD be taken seriously

For a while now (in fact quite a while) I’ve found that time after time within the web industry I’ve had to backup and support WordPress as a serious CMS contender.

It’s amazing to find so many so-called experts who believe that it’s not capable of do this, that or the other.  Or “it’s just a blog tool”, etc, etc.

Please people open your eyes!  WordPress is probably now the most popular CMS ever created to date (think it’s now betting Joomla?), its powering millons of sites and in particular only 6-8% are using it as a blogging tool.  Yep that’s right, the other 92% use it as a full-blown CMS – whether it’s for ecommerce, intranet, community, DMS or other!!

Anyway, enough of my moaning and groaning.  The clever people at Moove have provided a great infographic to say it all.  Launched in July, I can’t believe I’ve only seen this now!

WordPress in Numbers Infographic 2013

WordPress Home Page trick

When creating WordPress sites for clients, they often require a home page that needs updating but mainly feed from other pages e.g. news, carousels, etc.

Using a full “page” is often OTT as they’ll never create large amounts of content – sometimes it’s just a welcome message.

A great way to set this up then, is to use an over-ride for the default home page (you don’t even need to set to static page or alike).  To do this, simply create a front-page.php page in your template folder and viola – you can now set up your page as you want using your favourite text editor.

Using front-page.php I then add the carousels shortcode, custom code to bring in posts, etc.  As well as create some home-page specific widget areas for the homepage – allowing the editor to still have freedom to add/remove and customise content to produce a regular updated home page.

You could also use home.php but WordPress tends to think this is a variant of index.php and really used for display blogs.  WordPress will look for home before index.

Removing unwanted WordPress widgets from editor panel

I often find that most of my clients who use WordPress don’t use most of the standard widgets – often because they are using it as a CMS and not a heavy duty Blog.

A lot of the standard widgetst are features for comments, archives and a like.  A while ago I came a function in WordPress that you can use to unregister (and thus hide) these from the WordPress interface for your clients.  I’ve used it for a while but completely forgot until I needed to use it again recently.  So to help others (you lot probably already knew! lol) here’s the code:

As a heads up – you simply drop this into your functions.php in the theme you’re running.

// unregister all widgets
 function unregister_default_widgets() {
     unregister_widget('WP_Widget_Pages');
     unregister_widget('WP_Widget_Calendar');
     unregister_widget('WP_Widget_Archives');
     unregister_widget('WP_Widget_Links');
     unregister_widget('WP_Widget_Meta');
     unregister_widget('WP_Widget_Search');
     unregister_widget('WP_Widget_Text');
     unregister_widget('WP_Widget_Categories');
     unregister_widget('WP_Widget_Recent_Posts');
     unregister_widget('WP_Widget_Recent_Comments');
     unregister_widget('WP_Widget_RSS');
     unregister_widget('WP_Widget_Tag_Cloud');
     unregister_widget('WP_Nav_Menu_Widget');
     unregister_widget('Twenty_Eleven_Ephemera_Widget');
 }
 add_action('widgets_init', 'unregister_default_widgets', 11);

 

Yay! just passed my Google Analytics exam

Well a quick blog entry to boast about my pass for the Google Analytics exam (GAIQ) I finally got round to resitting today.

Had to reset the exam, as my last accreditation had expired (they last for 18 months) – so finally got to sit down today and take the challenge again!

Mist admit I found it harder than last time as it seemed to give me every ecommerce tracking and Adwords questions known to man – and unfortunately I don’t get chance to play around with these enough with my current job/clients.

So after around 40 mins of sweating it out with the exam I’m pleased to say I’m re-accredited for 18 months with a 91% pass rate :)   (Bit down from my 92% last time but I’m still pleased).

And here’s the proof via the Google StartTest profile page!

Show “Latest” blog entry on page

Ever wanted to put your latest blog post or maybe even latest 3) on your WordPress home page or maybe another “content” page in your site?  Well here’s a quick snippet of code which allows just that!

You can set how many “latest” blog posts you want (to change the amount just change the number in the entry get_posts(#)) and if you don’t want the full blog content, simply change the_content() to the_excerpt() for the short version;

<?php
         $lastposts = get_posts(1);
         foreach($lastposts as $post) : setup_postdata($post); ?>
               <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
              <?php the_date(); ?><?php comments_popup_link('No Comments &amp;#187;', '1 Comment &amp;#187;', '% Comments &amp;#187;'); ?>
                <?php the_content(); ?>
 <?php endforeach; ?>

Cookie monster is out to get you….

With the arrival of the cookie law coming up tomorrow, I don’t know if anyone else has noticed but the last few days have been busy times for companies/organisations as they implement and launch their “fixes”.

However what’s more interesting is the different solutions and “interpretations” of the directive – it seems that the ICO haven’t done the best (as we all know) on explaining in simple terms what is actually needed without any fluff….

Here’s Craig’s top list of “WTF should we do” attempts by organisations:

  1. The Telegraph – A nice clear link at the top, automatic consent and “toned” towards – its your issue not ours….
  2. Wales Online – we’ll give you 10 seconds to make your choice, if you don’t make one we’ll do it for you and assume you were okay ;)
  3. The Sun – we’ll do everything by the book, but make it slightly hard for you to see, hoping we get away with it :D
  4. HSBC – nice cookie policy but no consent option (similar to what we’ve been recommending for GA)
  5. NatWest – banner “inline” with content again similar but more prominent than our Sustrans
  6. About Cookies – Very safe approach – definite Yes/No request – however interesting that it sets a “No” cookie if no chosen…..
  7. British Gas – similar to many above, auto consent but a really nice approach to cookies landing page – more info than most (but possibly too much?!?)
  8. BT – Probably my most favourite and the first documented approach using the ICC attempt.  Still not perfect but their “choice” tool works similar to the old IE approach for security – if this tool could be tweaked slightly I reckon this could be virtually perfect.
  9. LittleWoods – I love this explanation attempt at cookies – a nice little video! lol
  10. ScrewFix – simple corner piece (bottom-right) which links to their cookie policy – like most no consent option and assuming you’re okay with it.
  11. NVida - Looks like another one based on the “Wolf PECR” approach (which seems to be the most used approach) – styled better than original but the “no” option is removed – thus it’ll stay in place until you say Yes.
  12. FastHosts - One of my favourite – nice styled box which float and then when chosen jumps to bottom.  Clearly asking Yes or No with a link for more info and allow people to change their mind and update when/if.

Umm… can’t find any more exciting ones yet, but watch this space :D

 

URL rewrite for pagination

A lot of sites I see using pagination all hit a similar problem.  The URL of the initial page looks lovely with no URL parameters or alike just news.aspx or news.php.

As you navigation through the additional pages the ?page=2, etc. gets added – again not too bad but the annoying bit comes when you click on the “page 1″ link again and instead of going back to that nice URL you just had, it simple appends ?page=1 to the end.

Now this works fine for us, visitors, etc. but the problem is this is really bad SEO – as two pages have the same content but spiders see this as two different pages.

So how about a fix?  Well it’s actually easy enough to do this through a rewrite rule – no additional coding or tweaking to the pagination code you have in place!  So here it is:

# Don't display pager for first page
  RewriteCond %{QUERY_STRING} page=1
  RewriteRule (.*) /$1? [L,R=301]

Responsive design sizes

Here’s the most popular sizes and max width for design for responsive design:

Desktop            1024×768             Run max 978px
Ipad landscape 1024×690             Run max 978px
Ipad potrait        768×946               Run max 748px
Iphone               320×356               Run max 300px
Iphone 4            320×356 x2           Run max 300px
Samsung          320(x1.5)x451      Run max 300px

Empty div gets bottom border on iPad/iPhone browser

Not sure if anyone else has been battling with this issue?  Let me explain – I built a set of templates that were tested in the usual suspect (IE6-9, FF3+, Safari 5+ Chrome 10+ Opera 10+) and all worked perfect! (albeit I had to use a dreaded IE6 CSS and conditional statement and the dreaded png fix!).

While I was at it I thought I’d just run a quick test on the Ipad/Iphone just to make sure – I honestly thought it would all be fine as I’d tested thoroughly on Safari for Windows and Chrome.  But to my dismay the “top” div I was using to hold a curved background image in and another I was using to hold a logo had strangely suffered from what looked like a 1px white border on the bottom of each div – obviously ruining my design!

Well I wasn’t going to let the Apple posse get one over on me so I turned to the trusty Google to find an answer – and luckily I did!  A single line of “meta” code in the header was all I needed to beat this Apple monster away :)

Here’s the code:

&lt;meta name="viewport" content="initial-scale=1, maximum-scale=1"&gt;

In a nutshell you need to tell the Ipad/Iphone not to play with the zoom scale at all – and viola it fixes the issue!

Useful WordPress navigation code

For most of my WordPress websites I tend to use an old but superb plugin called “Fold Page List” – this improves the standard WordPress navigation by showing child pages only when in a particular section! Perfect!

But what if I didn’t want to show the “whole navigation” on the left hand side when I went into section?!?!  Well as far as I can see I needed to create/use something custom.

So a search on Google came up with a few results but nothing really seemed to really do what I wanted, until I came across this post from TammyHart Designs – and it worked out perfect!

Made a few tiny tweaks to make sure the code validated so here’s  my reworked code (kudos to TommyHart for the original start though!):

&lt;?php if ( is_page() ) { ?&gt;
            &lt;?php
                if($post-&gt;post_parent)
                    $children = wp_list_pages('title_li=&amp;child_of='.$post-&gt;post_parent.'&amp;echo=0'); else
                    $children = wp_list_pages('title_li=&amp;child_of='.$post-&gt;ID.'&amp;echo=0');
                    if ($children) { ?&gt;

                    &lt;h2&gt;&lt;?php $parent_title = get_the_title($post-&gt;post_parent); echo $parent_title; ?&gt;&lt;/h2&gt;
                    &lt;ul&gt;
                        &lt;?php echo $children; ?&gt;
                    &lt;/ul&gt;
            &lt;?php } ?&gt;
        &lt;?php } ?&gt;

Still not perfect as I only want to show grand-children pages when you click on the child page – exactly what Fold Page list does – so looks like I’ll be doing a tweak to that involving the above really soon ;)