Categories widget show empty?

Not sure what you mean by ‘display all categories’, i thought it does that by default? Anyways…you can hook into it, using the following filter hooks: widget_categories_args widget_categories_dropdown_args Both hooks pass the query args to get the categories as an array. The default is array(‘orderby’ => ‘name’, ‘show_count’ => $c, ‘hierarchical’ => $h), wherein $c … Read more

What action hook can I use to add a JavaScript to a page post using a theme template that is not including get_header() nor get_footer()?

Completely skipping wp_head and wp_footer doesn’t seem like a good idea, many core components and plugins depend on these hooks. Instead, you could create a light header and footer, and load them via an extra argument to get_header() and get_footer(). get_header( ‘light’ ) will load header-light.php instead of the regular header file. Create one without … Read more

wp_enqueue_script before wp_head

Enqueue mechanics and suggested ways to use them serve flexibility and interoperability. Simply put consider what would be the easiest way for third party code to modify mechanics of yours? Hardcoding things in template often makes editing that template the only viable option. Manipulating hooks is typically more convenient and less problematic than that. On … Read more

Trying to alter the post_content through the_post

It seems you’re actually looking for the the_content filter. add_filter(‘the_content’, ‘modify_content’); function modify_content($content) { global $post; if ($post->ID != $desired_id) return $content; $modified_content = /* modify content here */; return $modified_content; }

How can I add a filter to a particular post format?

Use get_post_format(): function test_filter($content) { $format = get_post_format(); if ( ! $format ) return $content; if ( ‘audio’ === $format ) // do something with audio if ( ‘aside’ === $format ) // do something with aside return “$content <hr>post format: $format”; } Since the_content() requires a global $post object to work, get_post_format() will always … Read more

Wrapping my head around add_filter

Filters and Actions are similar under the hood, but with an important difference- Actions allow you to do something when an event occurs- WordPress does something and executes an action to let you do your own thing. A function hooked to an action may or may not produce output, but it never returns a value … Read more