Just found this awesome gist and had to share.
Ever wanted to change the ‘Enter title here’ placeholder text on a post or custom post type?
Just use this gist! Make sure you change the custom post type to whatever yours is or if you just want to change it for post, use ‘post’ (similarly ‘page’ for page):
So I was recently working on a new plugin that involved shortcodes but ran into a bit of a problem when the contents kept getting output at the top of posts/pages before the rest of the content.
Basically this happens because the shortcode is simply returning the data as soon as it’s generated it, not taking note to output it specifically where the user desires. Normally it’s because the content was echoed and not stored and later returned. You can read more about it in this great post but it’s really as simple as that.
However, I was recently faced with this issue and couldn’t figure out why! I was returning the data but it was still being output at the beginning of the post’s content before everything else. I was returning another function (that echoed the content) within my shortcode’s function but it wasn’t helping.
It looked a little bit like this:
DON’T DO THAT!
What you need to do is run the function through an output buffer with
ob_get_clean();, like so:
And it works! For the PHP nerds, you may be interested why we’re using
ob_get_clean(); instead of
ob_clean(); – then check out this discussion.
I came across this great snippet after some extensive searching and just wanted to share it to avoid others having to search long and hard just to find it. Authored by TheDeadMedic over on Stack Overflow, inserting the following into your
functions.php file will exclude the_post_thumbnail or featured image of a post from its gallery:
I’m now occasionally writing tutorials over on Wptuts+!
My first tutorial was released yesterday, Adding a Responsive jQuery Slider to Your WordPress Theme, which takes you through all the steps needed to do so.
Check it out and if you have any questions/thoughts, leave them there!
I decided to put together a small little WordPress plugin today, using the incredible fancyBox jquery lightbox.
It’s called Light, and it’s just that: a Lightbox and a light-weight plugin. No settings or detailed instructions or anything like that. Just install it and it works.
Want to see a demo? Cool. Here you go.
It’s actually pretty flexible, so I wrote a whole lot of documentation for it over on Captain Theme. You can view the documentation for it there.
Regarding the License, I personally don’t care what you do with the plugin but fancyBox is under a Creative Commons License that basically allows you to use it in personal/non-commercial projects for free but you have to pay if it’s for a commercial site (and you should – it’s well worth the money and the developer deserves it!). Read more about the fancyBox License.
It’s also on GitHub! How exciting. Check out the GitHub repository.
Have a question or need help? Leave it below and I’ll try to answer it.
Documentation / Demo
I came across this awesome snippet the other day that I thought I’d share and expand on it a little bit.
When you want to rename the title of a meta box, custom or core, the best way is to remove that meta box and then re-add it with a new title, using something like this:
You’ll need to change the fields above though for:
- METABOX_ID – eg. commentsdiv. See below for full list.
- META BOX TITLE – Whatever you’d like to rename the meta box.
- METABOX_CALLBACK – eg. post_thumbnail_meta_box – See below for full list.
- POST_TYPE – eg. post, page, etc.
When I struggle to find a clear answer to something and eventually come up with something that works, I like to repost it here so others can hopefully save themselves some time. This is one of those times.
If you want to display a random string from an array in WordPress, such as a random quote from a collection of your favourites, I’m going to show you how. Note that this isn’t a WordPress-specific solution, but I like WordPress and I like when you do too so I’m going to assume you’re using it*.
Recently when developing a site powered by Easy Digital Downloads, I wanted one of my products to display differently from the others in the store.
When this problem arises with pages, we can easily create a page template to solve the problem. However, when it comes to creating custom templates for other items such as posts and custom post types, we need a plugin. That’s where the incredible Custom Post Template plugin by Simon Wheatley comes in. By installing the plugin you can easily create templates for your posts, but what about for downloads? Also very easy due to the extensible nature of the Custom Post Template plugin.
This is such a cool little snippet. It’ll allow you to add a custom image size that you’ve added using <?php add_image_size() ?> to the media insert pop-up, so your custom image sizes can be inserted into posts as well as used through <?php the_post_thumbnail(); ?>.
Just add the following to your functions.php file:
Adjust as needed!
Quick little snippet here that may come in hand. If you’d like to add support for excerpts for a download when using Easy Digital Downloads, just add the following code to your functions.php:
You’ll then see the Excerpt meta box appear on the edit screen for downloads! You can output it using <?php the_excerpt(); ?>.