Exclude a WordPress Post Category across the whole site… but not custom queries.

Problem: On my latest project there’s a WordPress post category that only ever displays in a sidebar. I never want it to display in a ‘main’ loop posts on an archive page (whether it be the blog home, date archives, author archive etc etc. Until now I’ve been using ‘query_posts()’ and doing something like this in the main templates like home.php and index.php:

<?php $catObj = get_category_by_slug('my-cat-slug');
query_posts( 'cat=-'.$catObj->term_id );
if ( have_posts() ) :
	while ( have_posts() ) : the_post(); ?>
		<!-- Show stuff init! -->
	<?php endwhile;
endif;?>

This works… but I have to do it everywhere the loop is used, and when you dig into WordPress Templates that’s a lot of places.

Solution: There’s always a way to do something globaly in WordPress using Filters, Actions, or Classes in your theme’s functions.php file (or a plugin even). In this case we can use the ‘pre_get_posts’ action in functions.php to exclude the category for all main queries: Continue reading “Exclude a WordPress Post Category across the whole site… but not custom queries.”

Bower update failed with ‘ERR! error rolling back’

2018 update: Bower might not be the right thing to be using nowadays. Here’s a note from the Bower website: “…psst! While Bower is maintained, we recommend using Yarn and Webpack or Parcel for front-end projects read how to migrate!”


Problem: I just tried to update Bower with:

$ npm update -g bower

Which resulted in failure, and Bower wasn’t able to roll back so the install was fudged. Here’s some output of the errors:

$ npm ERR! error rolling back Error: EACCES, unlink '/usr/local/lib/node_modules/bower/.editorconfig'
$ npm ERR! error rolling back  bower@1.2.8 { [Error: EACCES, unlink '/usr/local/lib/node_modules/bower/.editorconfig']
$ npm ERR! error rolling back   errno: 3,

Solution: Firstly I stopped being a dork and remembered I’d need to add ‘sudo’ (the ‘Error: EACCES’ gives it away)… Continue reading “Bower update failed with ‘ERR! error rolling back’”

Golf MK3 Boot / Tailgate ‘grip molding’ fixing missing

Vehicle: 1996 Golf Mk3 VR6 Highline.

Problem: One of the 4 machine screws attaching the trim surrounding the hatchback / tailgate / boot lid lock mechanism was missing. This resulted in rattling, which is an irritation, but more seriously the trim bent every time the boot was opened. The original fixings are Torx headed with an integral washer.

Solution: The original fixing’s part number is N90626201 but it’s no longer available. Taking measurements from an existing fixing shows that the size is M5 x 14mm (standard 0.8 mm pitch), and fixings of this size are available all over the place. Be careful with the length, this fixing screws into a closed-head Rivet Nut welded into the panel. Continue reading “Golf MK3 Boot / Tailgate ‘grip molding’ fixing missing”

Super quick and dirty BBS Alloy Centre Cap overhaul

Problem: My old BBS alloys need a serious refurb, and the worst looking parts were the centre caps. I can’t afford a proper returb!

Solution: The centre caps are plastic, with a thin alloy stamped, painted and lacquered inset. Firstly I removed the plastic cap from the main alloy centrepiece. Continue reading “Super quick and dirty BBS Alloy Centre Cap overhaul”

Replacing the Blue Coolant Temperature Sensor in the Golf VR6 Mk3

Problem: My VR6 was having trouble starting and idling when cold. Many forums suggest this is due to a faulty “Blue” temperature sensor.

Solution – Testing the Sensor: To test the sensor while it’s fitted to the car, remove the latched plastic connector from the sensor and measure the resistance (Ω) between the 2 pins.
If the sensor is working correctly it should measure about:

  • 5500Ω at 0°c
  • 2500Ω at 20°c
  • 1250Ω at 40°c
  • 600Ω at 60°c
  • 325Ω at 80°c

I’m my case, the resistance was infinite, I.e. open circuit. So needed replacing.

Solution – Replacing the Sensor: The parts you will need are:

  • 1 x 2-pin Blue Sensor (VW: 025 906 041 A, GSF: 929vg014)
  • 1 x O-ring / Seal (know the part number? Please tell us in comments below)
  • Metal or plastic retaining clip (know the part number? Please tell us in comments below)

Continue reading “Replacing the Blue Coolant Temperature Sensor in the Golf VR6 Mk3”

Edit crontab with NANO on centos (crontab -e)

Problem: I don’t know where my root users crontab file is, and this doesn’t usually matter because using the command ‘crontab -e’ opens it for editing anyway… but it opens in VI and I am too stupid / lazy / in a rush to use VI.

[Edit – mid 2018: Earlier this year I went through about 3 weeks of IDE/Editor hell and taught myself Vim. It’s… wonderful]

Solution: The -e switch makes the file open in whatever the default editor for the environment is. To override this, pass the EDITOR environment var to the command when it’s run:

sudo env EDITOR=nano crontab -e

Please let me know if this nano tip was useful, just one click!
Nope, not helpful...Yep, more useful than not! - +74 thumb, 92 overall.
Loading...

Can’t activate Spotify Premium account on VodaFone 4G Red contract.

2017 Update: This tips is very old now, and the information is almost certainly out of date.

Problem: Just bought a new VodaFone contract that includes Spotify Premium (or Sky Sports something or other), and we website / in-store / 191 support don’t seem to know how I should actually activate it.

Solution: Send a text with the word ‘Entertainment’ to 97613. You’ll get a reply from VodaFone with a link and instructions. This worked at time of posting, 5s’s are new, 4G-ready contracts are new. Expect this to change.

How to use wp_get_attachment_image_src() properly…

Problem: No matter WHAT I do, wp_get_attachment_image_src() is NOT working. I JUST want the featured image source of this $post->ID.

Solution: Yes is probably is working… but stupidly I’m trying to pass it the POST ID and not the ATTACHMENT ID like I should be. The Attachment ID can be found with the get_post_thumbnail_id() function, and then passed like this:

1
2
$thisimg = wp_get_attachment_image_src(get_post_thumbnail_id($arr->ID),full);
print_r($thisimg); //shows the Array of bits you need.

Duh… me.

Please let me know if this post was useful with a click, be honest 🙂
Nope, not helpful...Yep, more useful than not! (No Ratings Yet)
Loading...

Warning: the CA certificate does not sign the certificate – Plesk 10 and GeoTrust Certs

Problem: After requesting a renewal QuickSSL Premium cert from GeoTrust, and uploading the Cert and CA Intermediates to the Plesk 10 interface, I’m warned that: “Warning: the CA certificate does not sign the certificate”.

Solution: Don’t worry about it! No idea why it happens. If you’re confident that you’ve added the correct Intermediate files, then go ahead and use one or two SSL Checkers like www.geocerts.com/ssl_checker and http://www.sslshopper.com/ssl-checker.html to confirm it’s all ok.

Notes: If there is a problem with the CA intermediate certs, it’s worth attempting to get them straight from the horses mouth. Sometimes the Intermediate cert you are sent along with your SSL Cert order isn’t enough. For all the current GeoTrust Intermediate certs, have a look here: https://knowledge.geotrust.com/support/knowledge-base/index?page=content&actp=CROSSLINK&id=SO15690

Please let me know if this post was useful with a click, be honest 🙂
Nope, not helpful...Yep, more useful than not! (No Ratings Yet)
Loading...

Zurb Foundation Tooltips for and WordPress thumbnails

Problem: I wanted to use Foundation 4’s tooltips on some WordPress post thumbnail (featured) images, but wasn’t sure how to add the necessary data attribute and classes.

Solution: It turns out after some playing about that an array of attributes can be passed to the WordPress ‘get_the_post_thumbnail()‘ function. Firstly we need to add the class ‘has-tip’ (and any extra positioning classes like ‘tip-top’ if that’s where we want the tooltip to appear – see the Foundation Docs link at the top). We then need to add the data attribute ‘data-tooltip’. An example of how to do this is in the following code where I pull out a value from an Advanced Custom Field, and display a list of images with tooltips:

1
2
3
4
5
6
7
8
$icons = get_field('accom_spec_icons');
if ($icons && !is_wp_error($icons)) {
	echo '<ul class="small-block-grid-4">';
	foreach($icons as $icon) {
		echo '<li>',get_the_post_thumbnail($icon->ID,'box-thumb',array('title'=>trim(strip_tags($icon->post_title)),'class'=>'has-tip tip-top','data-tooltip'=>'')),'</li>';
	}
	echo '</ul>';
}

It’s important to add the ‘data-tooltip’ attribute with a value of ”, otherwise it wont be inserted into the generated image tag correctly.