How to add automatically keyword to taxonomies when a post published, and assign them to the post

You would use the save_post hook, in your hooked function use wp_insert_term as described here: http://codex.wordpress.org/Function_Reference/wp_insert_term Then use wp_set_object_terms on the post to assignt he taxonomy term you just created as follows: http://codex.wordpress.org/Function_Reference/wp_set_object_terms for example: function my_save($post_id) { wp_insert_term( ‘bannanapost’, ‘fruit’); wp_set_object_terms( $post_id, ‘bannanapost’, ‘fruit’, true ) } add_action(‘save_post’,’my_save’); The above code, placed in functions.php … Read more

Get parent and first child taxonomy terms?

There is unfortunately no way that you are going to do this in one or two queries. It seems that there are a misunderstanding or misconception about database queries. The most important aspect to keep in mind when you are running database queries is the amount of database queries vs. the time these queries will … Read more

Add Thumbnail to wp_list_categories()

The original question uses get_tax_meta() which does not exist in WordPress core but may be a custom function created by the asker. In this case we could switch it out just as well with get_term_meta(). You could try this: class List_Category_Images extends Walker_Category { function start_el( &$output, $category, $depth = 0, $args = array(), $id … Read more

How to have “the most used tags” taxonomy always expanded?

There does not appear to be any way to hook into that from inside PHP http://core.trac.wordpress.org/browser/tags/3.3.1/wp-admin/includes/meta-boxes.php#L300 So JavaScript will probably best suit as a quick and easy solution. add_action( ‘admin_footer-post-new.php’, ‘wpse_45149_inject_script’ ); function wpse_45149_inject_script() { $expand_for = array( ‘post_tag’ ); // add taxonomy names here // build a nice jQuery query foreach ( $expand_for as … Read more

Set default (auto) slug prefix for Tags

You can use the created_term or the created_{taxonomy} hooks which are fired just after a taxonomy term is created (the second only if it matches the taxonomy). The following will only alter terms in the taxonomy ‘my-taxonomy’. (I believe for the default tags, taxonomy should be ‘post_tag’). add_action(‘created_term’, ‘my_add_prefix_to_term’, 10, 3); function my_add_prefix_to_term( $term_id,$tt_id,$taxonomy ) … Read more

How to set a Preset category for custom post types?

Try hooking into the save_post action to check the custom terms when a post gets saved: add_action( ‘save_post’, ‘set_default_category’ ); function set_default_category( $post_id ) { // Get the terms $terms = wp_get_post_terms( $post_id, ‘your_custom_taxonomy’); // Only set default if no terms are set yet if (!$terms) { // Assign the default category $default_term = get_term_by(‘slug’, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)