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

Taxonomy terms with edit/filter link in wp-admin, in the list of custom posts

It doesn’t have it wrapped inside a function you can use, but the following will work: $taxonomy = ‘my-taxonomy’; $taxonomy_object = get_taxonomy( $taxonomy ); $object_type = get_post_type($post_id); if ( $terms = get_the_terms( $post_id, $taxonomy ) ) { $out = array(); foreach ( $terms as $t ) { $posts_in_term_qv = array(); $posts_in_term_qv[‘post_type’] = $object_type; if ( … Read more

How to sort list of custom posts to get view like a tree of posts under categories and their children’s categories?

ok, this is my working solution: <?php $args=array( ‘post_type’ => ‘biblioteka’, ‘child_of’ => 0, ‘parent’ => ”, ‘orderby’ => ‘name’, ‘order’ => ‘ASC’, ‘hide_empty’ => 1, ‘hierarchical’ => 1, ‘exclude’ => ”, ‘include’ => ”, ‘number’ => ”, ‘taxonomy’ => ‘kategoria-pozycji’, ‘pad_counts’ => false ); $categories=get_categories($args); foreach ( $categories as $category ) { if ( … Read more

wp_options table value

The only really interesting (and very important) part of the 3rd query is this: ‘project_location_children’, ‘a:7:{i:22;a:1:{i:0;i:23;}…etc…}}’ The a:n:{i:n; etc } stuff is a serialized PHP array. WordPress – for some historical reason – keeps track of term children in one option entry per taxonomy term. The painful thing is, that a lot of people don’t … Read more

Convert IPTC keywords to blog post tags

WordPres has a function that extract IPTC info from images, that function is wp_read_image_metadata. That function is only available on admin side and, according with the codex, it doesn’t extract IPTC keywords. But you can use iptcparse from PHP at your own to extract IPTC keywords and set them as post tags. In your question, … Read more

Taxonomy rewrite question

Your permalink structure for taxonomy will conflict with default one for pages. In the case of the address domain.com/item-one/item-two how does WordPress know if it’s a page item-two with the parent page item-one or item-two is custom post type and item-one is term of region taxonomy? The order of rewrite rules will decide, and because … Read more

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