Add default content to post (for specific category)

default_content runs when a post is loaded into the editor, actually. You can check for categories when the post is saved, but you’d want the save_post hook, probably. You want to check the $_REQUEST global. add_filter( ‘default_content’, ‘my_editor_content’ ); function my_editor_content( $content ) { global $_REQUEST; if (isset($_REQUEST[‘post_category’]) && in_array($some_category_id,$_REQUEST[‘post_category’])) { $content = “My html … Read more

WP_Query search by multiple meta key and distance

You can do that. There are filters available in WP_Query that enable you to modify the query just as you like. The filter posts_clauses filters all of the parts of the query together. There are also filters specific to the parts of the query too. The best way to know about them is, search posts_clauses … Read more

Restrict category choice in dropdown menu?

Well after thinking about this some more, I’ve realised that it was a bit of a dumb question to ask… My problem is actually being able to pre-define categories in themes for new subsites of my mulitiste. I’ve got around this by using a premium plugin which allows me to offer blog templates / themes … Read more

Sortable columns by meta value holding a date – can’t get it to work

Is it not an option to insert the sorting directly to the WP_Query class? It has all the parameters for handling this kind of situation http://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters If you want to do that in the code, you can first validate all the dates, then convert them to the standard ISO(yyyy-mm-dd) format & then use the standard … Read more

Query author’s posts & posts that have author’s id as meta value

Instead of a new WP_Query, use the pre_get_posts filter add_filter(‘pre_get_posts’, ‘custom_query’); function custom_query($query) { if($query->is_main_query() && $query->is_author() && $_GET[‘eco’]==’somemetakey’) { $query->set(‘meta_query’, array( array( ‘key’ => ‘somemetakey’, ‘value’ => $query->get(‘author’) ) )); } }

Trying to get fittext to work in WordPress

I figured it out finally, for some reason using the $ in my script just doesnt work so I had to use jQuery instead like this <script type=”text/javascript”> jQuery(document).ready(function() { jQuery(“#fittext3”).fitText(1.8, { minFontSize: ’12px’, maxFontSize: ’75px’ }); }); </script>

RSS feed – get specific item from external feed

Displaying feeds usually links out of your site to the rest of the original content. You will have to use feeds that display all the content (or enough to show on your own pages) and then pass that information to a page using a template that can receive and display it. An alternative is to … Read more