How to retrieve custom field types for all posts in WordPress/PHP?

Custom fields are saved as “post meta” which is stored in wp_postmeta. To retrieve them, you use the get_post_meta() function as follows: $value = get_post_meta( $post_id, $meta_key, $single ); $single will almost always be set to true if you’re working string data. Unfortunately, it defaults as false, so if you’re retrieving the data as a … Read more

Relative Time On Posts

WordPress actually has an obscure and little known function called human_time_diff() that does this. It takes two arguments; the first is the earlier timestamp, and the second is the later timestamp. Both should be Unix timestamps. The first argument is required, but the second is optional, and will use time() if left empty. So, for … Read more

What are the Theme tags in style.css used for?

The theme tags are used to sort/categorize themes in the WordPress theme directory according to features or characteristics. For example, if your theme supports two columns (a typical blog format), then you use the two-columns tag and if it supports multiple screen sizes, use the responsive-layout tag. This makes it easier for someone looking for … Read more

Workflow and best practice for documentation [closed]

Great question. There is no generic and comprehensive documentation workflow in WordPress circles. However there are some nice tools and options to make use of. readme.txt Markdown-based machine-readable file. It’s main purpose is to be parsed and presented by official plugin repository, but it’s not too convenient outside of that. It is great and fitting … Read more

how do I get a sidebar’s id or number for use with is_active_sidebar()

Found a solution to the problem. I added a line of code id => ‘my-sidebar-id’ to the register_sidebar array so now i know the sidebar ID. There may be another way of doing it but this method seems to work fine for me now anyway. if ( function_exists(‘register_sidebar’) ) register_sidebar(array( ‘name’ => ‘Right Sidebar’, ‘id’ … Read more