Skip Navigation

[Resolved] How to display a CPT in widget by its post_id?

This support ticket is created 7 years, 3 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 2 replies, has 2 voices.

Last updated by jeffS-2 7 years, 3 months ago.

Assisted by: Minesh.

Author
Posts
#564074

Tell us what you are trying to do?
I have two sidebar widgets: one displays my organization's events (Upcoming CSNV Events) and the other displays Upcoming "Other" Events. However, I have one particular "Other" event I need to have displayed under the Upcoming CSNV Events widget. I tried adding the post_id to post__in with a wpv_filter_query but, I can't make it work. Since the View for this widget already contains two filters using AND, I cannot easily add this post_id to the View filter because it would need to be ORed with the other filters.

I have successfully used post__not_in with a wpv_filter_query for not displaying this particular event in its normal widget ("Other").

I have the following non-working filter:

// Upcoming OTHER Events - Show special SV2017 in Upcoming CNSV Events rather than Upcoming OTHER Events
add_filter( 'wpv_filter_query', 'show_special_SV2017_event_func', 10, 3 );

function show_special_SV2017_event_func( $query_args, $view_settings, $view_id ) {
    $SV2017x[0] = 22772;
    if ($view_id == 623) { 
//		$query_args['post__in'] = $SV2017x[0];
//		echo '<pre>YY'; print_r($query_args['post__in']); echo 'YY</pre>';
    }

    return $query_args;
}

What is the link to your site?
hidden link

Thanks,
Jeff

#564109

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - could you please share more information about which category you would like to include and with which view and the problem URL where you would like to display it.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I would additionally need your permission to de- and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important. If you agree to this, please use the form fields I have enabled below to provide temporary access details (wp-admin and FTP).

I have set the next reply to private which means only you and I have access to it.

However, here are few links that shows how you can manipulate code inside wpv_filter_query hook:
=> https://toolset.com/forums/topic/parametric-search-keeps-displaying-wrong-results/#post-357800
=> https://toolset.com/forums/topic/help-with-category-filter-on-search/page/2/

#564530

No reply.