Support » Plugin: Custom Post Type UI » dynamic tax from another custom post type content

  • Resolved dgirona

    (@dgirona)


    I need create dynamic tax from another custom post type.

    example.

    cpt1 = bancos

    cpt2 = prestamos
    tax = content of cpt1

    Any idea?
    Thanks : )

    The page I need help with: [log in to see the link]

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Michael Beckwith

    (@tw2113)

    The BenchPresser

    Honestly not sure how I’d go about attempting that, and it’s sounding well above the intents and capabilities of CPTUI which is meant to handle just the individual registrations for given content types.

    Thread Starter dgirona

    (@dgirona)

    I think it’s a very common possibility. Imagine the following project:

    A CTP for banks.

    And various other CTPs for loans, mortgages, cards, financial products, which are related to banks.

    Therefore bank would be a taxonomy in all these financial products…

    It would be a valuable extra functionality for your plugin.

    A taxonomy that could be a copy of a cpt or even another taxonomy.

    Imagine this CTP as a brand. You might have some products (cpt too) that use this brand. I think it’s a very common thing.

    This with woocommerce is more common. But of course, for this type of project it is not necessary to install woocommerce, it loads the system a lot, and a payment gateway is not needed, nor all the functionalities of woocommerce.

    Well it’s just a suggestion.
    I’m going to look

    Plugin Author Michael Beckwith

    (@tw2113)

    The BenchPresser

    Maybe I’m not fully understanding.

    You can create post types and taxonomies and assign the taxonomies to given post types. For example the “post” post type and “category” and “post_tag” taxonomies.

    The way I’m reading this, or at least the way I believe I am, is that you’re talking about using or cloning post type posts as terms in a given taxonomy?

    Thread Starter dgirona

    (@dgirona)

    yes i correct Look at the example of banks that I have exposed. banks is a type of content, which in turn is a taxonomy of other types of content. I think it is a very good function to be able to create dynamic taxonomies. It’s like the brans module for woocommerce, it manages brands for woocommerce. It would be the same but for cpt.

    Thread Starter dgirona

    (@dgirona)

    I suppose that the approach would be: when a new content is inserted in cpt1, a new term should be inserted in the taxonomies in cpt2, cpt3 …

    if the name is changed in cpt1, the name of the taxonomy in cpt2, cpt3 … would have to be updated. if the cpt1 is deleted, we would have to delete the taxonomy in cpt2, cpt2 …

    • This reply was modified 4 months, 1 week ago by dgirona.
    • This reply was modified 4 months, 1 week ago by dgirona.
    Plugin Author Michael Beckwith

    (@tw2113)

    The BenchPresser

    I know that WooCommerce with their attributes taxonomy, uses that to create new taxonomies/terms, but that’s still taxonomy -> taxonomy, not post type -> taxonomy.

    That said, based on your last comment regarding publishing posts and creating terms from that information, it is going above what we’re wanting to handle with CPTUI at this time.

    In the meantime, I am able to visualize at least some of what would need to be done to achieve that. Mostly listening to wp_insert_post based hooks and in that, creating/updating taxonomy terms based on the getting saved data.

    Thread Starter dgirona

    (@dgirona)

    // insert bancos cpt into tax banco_prestamos

    add_action( ‘publish_bancos’, ‘add_banco_term’ );
    function add_banco_term( $post_ID ) {
    $post = get_post( $post_ID ); // get post object
    wp_insert_term( $post->post_title, ‘banco_prestamos’ );
    }

    // delete tax banco_prestamos when delete cpt bancos

    add_action( ‘wp_trash_post’, ‘action_delete_taxonomy’ );
    function action_delete_taxonomy( $post_ID ) {

    $taxo = get_the_title($post_ID);
    $tipo_post = get_post_type( $post_ID );

    if ( $tipo_post == “bancos” ){

    // prestamos
    $terms = get_terms(‘banco_prestamos’, array( ‘hide_empty’ => false ) );
    foreach ( $terms as $term ) {
    if ( $term->name == $taxo ) {
    $banco_cat_id = intval( $term->term_id );
    wp_delete_term( $banco_cat_id, ‘banco_prestamos’ );
    }
    }
    }
    return;
    }

    ¿update?

    Plugin Author Michael Beckwith

    (@tw2113)

    The BenchPresser

    I don’t have any sort of update as I haven’t been trying anything with this. I know I provided some visualized ideas of how to potentially handle this based on how I’d attempt it, but hadn’t proceeded any further. It’s not really a support question around CPTUI itself at this point, but more different ways to make use of the post types and taxonomies that were registered.

Viewing 8 replies - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.