WordPress: Super useful WP-config tips

WordPress: Super useful WP-config tips

The wp-config.php file is the heart of your WordPress website, where you can define a wide variety of options to control how your WordPress install works. Today, I'm sharing with you a list of super easy tips to take more control of your site using wp-config.php.
Blogging 101
1.7Give Your Review

Blogging 101

Blogging 101 Blogging 101 is mostly about the blogging vocabulary. To understand blogs, you need to know the terms blog, platform, domain, and web host.
How to Convert a date / timestamp to time ago for posts

How to Convert a date / timestamp to time ago for posts

How to Convert a date / timestamp to time ago for posts Displaying an exact date on your posts is great but why not change things up just a little and display “1 Hour Ago, 2 Hours Ago, 1 Day Ago, 2 Days Ago, 1 Week Ago, etc. Just add this snippet to your single.php, index.php or any other template within the loop and you are good to go. ( CLICK CODE TO COPY ) WORDPRESS SNIPPET : PHP <> echo human_time_diff( get_the_time('U'), current_time('timestamp') ) . ' ago'; ( WordPress codex functions, hooks, in this snippet. ) get_the_time, the_time, current_time, human_time_diff,
How to Track post views without a plugin using post meta

How to Track post views without a plugin using post meta

How to Track post views without a plugin using post meta Use the following snippet to track post views on your wordpress blog. The first thing you want to do is add this snippet to the functions.php of your wordpress theme. Follow step 1. and step 2. to track and display the number of views for each post. Updated this snippet from my original post on March 3rd, 2011 to Included a option for Fragment Caching so this snippet will work even on cached pages.
How to Remove featured image when deleting post with wp_delete_attachment
0.0Give Your Review To This Article

How to Remove featured image when deleting post with wp_delete_attachment

In a recent project I needed to create posts and upload images from the front end as featured image. So as a result I also needed to remove these attachments when people deleted the posts. Otherwise we would have a lot of orphan images using up lots of precious space in our WordPress Media Library. Adding this snippet to the functions.php of your WordPress theme will remove featured images when you delete a post using before_delete_post hook. You will want to be careful with this snippet if you attach the same image to multiple posts as the featured image so keep that in mind. One other thing to remember is that media library items are deleted when the post is deleted not put into trash so you will need to fully delete the post to see the image removed. ( CLICK CODE TO COPY ) WORDPRESS SNIPPET : PHP <> add_action( 'before_delete_post', 'wps_remove_attachment_with_post', 10 ); function wps_remove_attachment_with_post($post_id) { if(has_post_thumbnail( $post_id )) { $attachment_id = get_post_thumbnail_id( $post_id ); wp_delete_attachment($attachment_id, true); } } ( WordPress codex functions, hooks, in this snippet. ) delete_post, get_post, has_post_thumbnail, wp_delete_attachment, add_action, wp,