WordPress.org

Ready to get started?Download WordPress

Forums

Post From Site
[resolved] Can't attach taxonomies. (2 posts)

  1. Takahashi Fumiki
    Member
    Posted 2 years ago #

    I user Post from Site 3.0.1 and this is a greas plugin.

    But in my situation, specified taxonomy weren't attached to the post.
    Below is the case.

    Allowing to attach taxonomy, a post form will be output.
    The taxonomy is displayed as select box, and each select box has it's terms as option tag.
    When taxonomy is hierarchical (i.e. category), it has term_taxonomy_id as value attribute, otherwise (i.e. post_tag) term slug.
    Problem is 'term_taxonomy_id' on option tag.

    See /post-from-site/post-from-site.class.php at ll.371-378.

    In most situations this causes nothing because term_id and term_taxonomy_id are same, but sometimes aren't.
    This causes unexpected result because this plugin process taxonomies finally with function 'wp_set_post_terms' which requires an array of 'term_id'.
    If PFS misses taxnomies or attaches wrong taxonomeis, the solution is below.

    If you have the custom taxonomy 'Foo' and it has the same term(i.e. Tokyo) as default taxonomy 'Category', you have to hook in functions.php like this:


    add_filter('pfs_foo_list', '_replace_pfs_pulldown');

    functoin _replace_pfs_pulldown($output){
    return preg_replace_callback("/<option value='([^']*)'/", '_replace_pfs_callback', $output);
    }

    function _replace_pfs_callback($matches){
    $match = $matches[1];
    if(is_numeric($match)){
    global $wpdb;
    $match = $wpdb->get_var($wpdb->prepare("SELECT term_id FROM {$wpdb->term_taxonomy} WHERE term_taxonomy_id = %d", $match));
    }
    return "<option value='{$match}'"
    }

    That's all. Hope it help someone and my Saturday was wasted :p

    http://wordpress.org/extend/plugins/post-from-site/

  2. elpitaj
    Member
    Posted 2 years ago #

    Hello Takahashi,

    I try doing this but still doesn't work.

    :(

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic