@font-face in your Face

I got this jewel of an error this morning while checking a site in IE10 that I hadn’t run across before.

CSS3117: @font-face failed cross-origin request error

Of course, it was glaringly obvious that the site hadn’t loaded the fonts I intended for it to load so the connection wasn’t being made. I did some quick searching and the “cross-origin” request in this case was that I hadn’t yet specified whether or not the site was to be only ‘www’ or non-www so the discrepancy apparently was enough to flag a security problem in IE. After adjusting the .htaccess file to route all traffic to the ‘www’ subdomain, all is working fine.

Hope that helps someone else out there.

Excluding Posts from Blog Page in WordPress

Ok, this one seemed to trip me up quite a bit when I had a client ask to exclude a certain category from the main blog page in WordPress. For example, if you have a category of “news” or a category of “events” that you don’t want to show up on your main blog page you’ve designated in WordPress just add this snippet to your theme’s functions file at the bottom before the closing php tag “?>”,  if there is one in your theme.

// Exclude news and events category posts from specified blog page

function exclude_category($query) {
if ( $query->is_home() ) {
$query->set(‘cat’, ‘-6 -7’);
return $query;
add_filter(‘pre_get_posts’, ‘exclude_category’);

Note that in this case, category 6 was my “news” category and category “7” was my “events” category. So, in this query I’m simply prefixing the numerical id with a minus to exclude it from the results.

The full details can be found on the good ol’ WordPress Codex here – http://codex.wordpress.org/Class_Reference/WP_Query

Hopefully that’ll help some poor soul searching for this seemingly simple task out there.


Drupal Views PHP and Text Values

Man, after much tinkering and frustration I have finally realized that when using Views PHP to construct fields you cannot print actual text values out. Instead it will produce the entity number in your output code.

So, in case you are trying to get a Global PHP field to write out an actual value from your database using a $row variable it’s not going to work. You’ll end up with the entity number instead of the text you’re retrieving. Either you have to use a Global text field and available tokens or retrieve the raw text like this using $data:

<?php print ‘<p>This is the text here. And, here is your ‘ .$data->field_field_yourvalue[‘0’][‘raw’][‘value’]. ‘</p>’; ?>

Here’s some more detail on this if anyone is interested. http://drupal.org/node/1140896

YouTube iFrame and Dropdown Menus

Ever get that annoying issue where your drop down horizontal menu expands down and the YouTube video you embedded with the standard iFrame code remains on top of your menu? This one has buggered me a few times and maybe I’m not the only one but I figured I’d share how to resolve this.

Basically there’s a z-index problem here where iFrames want to always be on the top of the window. The fix is to use a parameter in your embed code from YouTube.

Simply add “?wmmode=transparent” to your video url in the embed code. Here’s an example.


What it does

Well, wmode=transparent is nothing new but rather an old-school method to explicitly declare layering instructions when using .swf embeds. The “transparent” basically tells the browser to render the .swf below everything that could be positioned above it in a layout.

Hopefully that was useful for someone.

Copyright Year Automatic Update

I hate having to go in and manually update the year in the footer on websites next to the copyright text. This isn’t anything fancy or new but just something to keep in your brain so you don’t have to go around updating the year every January in your website footers.

Simply use this little bit of PHP and it’ll update automatically:

<?php print date(‘Y’);?>

So, for example your html might look like this:

<p>&copy;<?php print date(‘Y’);?>, Josh Merriam, maker of websites. Don’t steal and stuff.</p>