List all posts connected to another single post when not viewing a post
-
Good morning,
I’m trying to filter the Posts table in the admin to show only Posts that are connected to a certain Person. I have added a custom column to the table to show who is connected, with each name being a link.
When the link is cliked, I am using therequest
filter to manipulate the query, but I cannot figure out what I need to do.I’ve tried using he ID of the Person for
'connected_items'
but no results are returned, I’ve also tried not using'connected_items'
, but that throws up an an error.For example – URL =
https://test.dynedrewett.com/wp-admin/edit.php?post_type=post&contact=458
, wherecontact=458
is the ID of the person whose connections I want to show.function filter_custom_columns($vars){ if(isset($_GET['contact']) && $_GET['contact'] !== '') : $new_vars['connected_type'] = 'news_to_people'; $new_vars['connected_items' ] = $_GET['contact']; $new_vars['direction'] = 'from'; endif; return $vars + $new_vars; } add_filter('request', 'filter_custom_columns');
Here is the regestered connection –
p2p_register_connection_type(array( 'name' => 'news_to_people', 'from' => POST_TYPE_NEWS, 'to' => POST_TYPE_STAFF, 'title' => array('from' => 'Staff linked to this Story', 'to' => 'Stories that this Staff Member is linked to') ));
Any help here would be appricated. Thanks.
- The topic ‘List all posts connected to another single post when not viewing a post’ is closed to new replies.