• Resolved philipbadilla

    (@philipbadilla)


    Hi Guys,

    I’m doing a custom query using WP_Query.
    How can I filter my results so that I can only get POSTs that was broadcast-ed from in a specific blog.

    Basically we have.
    blog1,
    blog2,
    blog3,
    blog4,

    Anyone can broad cast and target any other blog within the multisite,

    Now for the search page, we want the ability to filter the posts by blog,

    e.g. Show only posts that came from blog2 or broadcast-ed to blog2.

    I appreciate any help. Thank you!

    https://ww.wp.xz.cn/plugins/threewp-broadcast/

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author edward_plainview

    (@edward_plainview)

    This is, unfortunately, impossible considering how the link data (broadcast_data) is stored, in a separate table.

    Perhaps a workaround would be to add a specific tag to broadcasted posts, and search for those tags?

    Thread Starter philipbadilla

    (@philipbadilla)

    Thank you for your reply. Is there a hook so I can create a tag every time a post is broadcated/un-broadcasted.

    Or how about hooking or adding filter in WP query so I can join your table and also filter the results?

    Plugin Author edward_plainview

    (@edward_plainview)

    There are several hooks.

    threewp_broadcast_post_action
    threewp_broadcast_broadcasting_before_restore_current_blog

    For example.

    Using the second one you could add a specific taxonomy during broadcast, for example.

    Thread Starter philipbadilla

    (@philipbadilla)

    Thanks, i’ll try it. If you know any sample code it would be helpful. I appreciate your help!

    Thread Starter philipbadilla

    (@philipbadilla)

    What I did was hook unto the
    threewp_broadcast_broadcasting_before_restore_current_blog

    and got the
    $bcd = $action->broadcasting_data;
    $origin_blog_id = $bcd->broadcast_data->blog_id;
    $origin_post_id = $bcd->broadcast_data->post_id;

    And checked for child post like this

    $broadcast_data = ThreeWP_Broadcast()->get_post_broadcast_data($origin_blog_id, $origin_post_id);
    $children = $broadcast_data->get_linked_children();

    Then just foreach to all the children and created post_meta keys so I can filter them later using WP_Query

    Plugin Author edward_plainview

    (@edward_plainview)

    Looks good. I’m trying to figure out if it’s a good idea or not to move the link data into the postmeta of each post.

    Haven’t come to a conclusion either way.

    Thread Starter philipbadilla

    (@philipbadilla)

    Yup things to consider when going in this direction is to make sure we handle un-linking/re-linking and deleting of children and update the postmeta.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘WP_Query Filter with Broadcast’ is closed to new replies.