We Blog

A store of our collected wisdom.

Check for mobile and redirect

So today I needed to send users on mobile devices to an external URL. That's easy enough, but the client needed users headed to a different external URL if they were headed to one particular section of the site. In the code below, I use wp_is_mobile to test the browser; if true, then I check the page they've requested. If it's that page or any of that page's children, they're redirected to one URL. If it's mobile but not that page, they're redirected to a different URL. Works perfectly! … [Read more...]

Don’t block me, bro!

I hate it when websites pop up ads – or worse, those survey things – over the top of the content I'm trying to read. Seems like this guy feels the same way. The worst case I've seen was with a local funeral home. I was sitting in a meeting with a funeral director client and we were discussing a feature he wants to add to his site. We were poking around the web to see if any of his competitors were adding the same service to theirs, and we happened across the site of one of the larger funeral homes in the area. These guys had added a pop-up survey to their site! Our mouths literally dropped open when the window came up; who in their right mind would agree to take a … [Read more...]

Fetch and display the contents of a specific post by ID

Once in a while you come across something that is so simple and yet so immensely useful. I needed a simple way to display the contents of a post inside a page template. I'd set up a CPT for "Content Blocks" so that a user could create custom content and I could then display that content in a specific "content block" in a page template. Enter get_post(). … [Read more...]

Tribe Events Manager CSS bug

Joe found a problem with Modern Tribe's Events Manager PRO plugin today. He wanted to change something on a recurring event, but when he tried to save the change, he had a window popup asking if he wanted to change just the one event, or all of them. The problem was that the button wasn't clickable. The whole screen was greyed out. Having seen this before, he poked around in the code for the page and changed the z-index to the ridiculously high: z-index:1000000; in order to gain access to the button. The bug has been duly reported. … [Read more...]

Rapid WordPress site setup via Terminal

Setting up a new WP site is pretty quick, but it's still tedious after you've done it dozens of times. We've been combing the net, looking for ways to make it happen really quickly. Here's what we have so far: … [Read more...]

Nested Conditionals in WP Events Manager

Today I had to troubleshoot an Events Manager issue which turned out to be caused by the plugin's code being set up to process one conditional at a time. For example the following code will execute only the first conditional, {is_future}{/is_future}: {is_future}  {has_image}Show the image as #_EVENTIMAGEURL{/has_image}  {no_image}Show a default image{/no_image} {/is_future} The {has_image} and {no_image} conditionals will be ignored. To fix this you must manually edit your wp_options table: option_name = dbem_conditional_recursions option_value = 2 Set the value to 1 or more. In this case you would use 2 since there are 2 nested conditionals … [Read more...]

Center menus in Genesis

It drives me nuts that there's no obvious, easy way to center the nav bar in Genesis (or, to be fair, in most WordPress themes/frameworks). Stumbled across this the other day and found it works really well. If you are using a subnav, change #nav to #subnav in the above CSS. If you are using both the top menu and the bottom menu, use two versions of the CSS: one for #nav and one for #subnav. It is possible to write it as, for example, #nav .wrap, #subnav .wrap {} etc… to minimize page sizes. (Lifted from journalxtra.com) … [Read more...]

Detect Mobile Browser and Serve Up Alternate Content (or nothing)

The site we just built for faithandform.com has a pretty cool slideshow feature on the home page, serving up a portion of the four most recent issues' cover images and tables of content. But it doesn't work well at all on small mobile devices, so Joe and I spent some time poking around the tubes until we worked this out: Which is all based on a post we found here. (You're going to need this file, too.) (edit: Here's a place to find out how to use is_mobile) … [Read more...]

YouTube and Vimeo Embed Shortcodes

We don't always need a full-blown plugin to do something like embed videos, especially if we'll be doing the site updates, so we whip up shortcodes to handle that kind of stuff. Here's a simple one to pull in videos from YouTube and Vimeo. … [Read more...]

Fix Double Sidebar Problem with Genesis CPT Archives Plugin

[Read more...]