• Resolved erioch

    (@erioch)


    Hi,

    I have this mybook table plugin and I would like to pull related materials based on the tags in the pages in the main website, however, when creating tags that are similar to those in the main core wordpress, the slug is given a diferent identity and since if you use the name of the tag, there are those with many diferent words that are not treated as one;

    Example, if I have “Evaluations” tag in the main page, I need it to pull books with “Evaluations“, but since the evaluation in my book table will have will have this “Evaluations-1“, it becomes a problem to use a slug since they will not be the same identical item, the second option would be to use the name in stead of the slug, and this is also a problem since if we have “Evaluations Report“, they would be pulled together with “Evaluations” since they have two words of Evaluations, is there a way to go around this?

    I.e create a tag for the main page and create the same tag in My Book table then pull them together using the standard get tags query?

    I would really appreciate any advice on how I can achieve this.

    https://wordpress.org/plugins/mybooktable/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author zookatron

    (@zookatron)

    The MyBookTable book tags are a completely different taxonomy from the built-in WordPress post tags, so you can’t normally pull books and posts in a single query easily. Also, books will not display properly if treated like posts, so I’m not sure how you plan on using this query exactly.

    Are you trying to do this query with PHP code? If so, could you post the code here so I could try to get a better idea of what you’re trying to do? I’m somewhat confused as to what the end result you are trying to achieve is.

    Thread Starter erioch

    (@erioch)

    Hi,

    Thank you for the reply.

    This is the code I was trying to use…

    <?php
    
    // Generate an array of taxonomy IDs
    $tax_IDs = array();
    foreach ($tags as $tag) {
        $tax_IDs[] = $tag->ID;
    }
    
    // Use your array of taxonomy IDs in the query args
    $args_2 = array(
      'post_type' => 'mbt_book',
      'post__not_in' => array($post->ID),
      'showposts'=> 3,
      'tax_query' => array(
            array(
                'taxonomy' => 'mbt_tag',
                'field' => 'id',
                'terms' => $tax_IDs
            )
        )
    );
    
    // Run your query
    $my_query_2 = new WP_Query($args_2);

    I hope this will give an indication…

    Kind regards

    Plugin Author zookatron

    (@zookatron)

    Hey Erioch,

    I’m still confused as to what exactly you are trying to achieve. In your first post you said you wanted to “create a tag for the main page and create the same tag in My Book table”, what is the “main page” that you are talking about? Can you be more specific about what exactly you are trying to achieve?

    As for your code, it seems to be properly querying the books for all books that have any of the given tags, so I’m really not sure what the problem you are seeing is.

    Thread Starter erioch

    (@erioch)

    Hi zookatron,

    I managed to get a work around, thanks for the support though…

    I decided to use the conventional post_tag option instead of the mbt_tag and it seems to work…

    The idea was to use the pool of tags added by the conventional wordpress tags system instead of adding tags differently between mbt_book and wp-post…

    It is now working well as expected.

    Another NOTE: I managed to create featured image support for anyone who wants to pull thumbnails as well by adding featured image in addition to the book image. I realized that the normal wordpress thumbnail functionality does not recognize book image, so by adding ‘support’ => array (‘title’, ‘thumbnail’); creates the add featured image meta field for that purpose.

    Kind regards,

    Erick

    Plugin Author Thomas Umstattd

    (@neovita)

    Whoops. Posted in the wrong thread. Moderators you can delete this.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Pulling related materials from my book table in pages’ is closed to new replies.