Views is a WordPress plugin that lets you easily display content on your website's front-end in any way you choose.
Views User Guides include detailed documentation for creating lists of content, templates for content and archive page and also explain how to create parametric searches for any content type.
When you ask for help or report issues, make sure to tell us the versions of the Toolset plugins that you have installed and activated.
Viewing 15 topics - 1,681 through 1,695 (of 3,129 total)
Problem: I would like to display a View of related posts in an M2M relationship. There is checkbox in the intermediary post type (in the relationship) and I would like to display only those related posts where the checkbox is unchecked.
Solution: This requires some custom code, and it also requires that the View is configured to display the intermediary post type. Add the following code snippet to filter by an unchecked checkbox:
add_filter( 'wpv_filter_query', 'unchecked_ints',99,3 );
function unchecked_ints( $query_args,$views_settings, $view_id) {
global $post;
$field_slug = 'release-artist-checked';
$views = array( 48324 ); /* "Collaborations" */
$ints_args = array(
'query_by_role' => 'child',
'role_to_return' => 'intermediary',
'limit' => 1000,
'offset' => 0,
'args' => [
'meta_key' => 'wpcf-' . $field_slug,
'meta_value' => 1,
'meta_compare' => '='
]
);
$ints = toolset_get_related_posts( $post->ID, 'supporting-artists', $ints_args);
// you should not need to edit below this line
if ( in_array( $view_id, $views ) ){
$query_args['post__not_in'] = $ints;
}
return $query_args;
}
Problem: I have a View that displays posts. I would like to add a button to each result that triggers a popup dialog with more information about each post. Is there a plugin or addon available for displaying popups with Toolset?
Solution: Toolset does not provide a built-in popup or modal dialog component, but gives you the ability to enqueue the Bootstrap library in Toolset > Settings > General.
The Bootstrap library comes with a built-in modal component that can be used to display popups like you have described.
There is no built-in integration for modals like these in the Block Editor, so custom HTML is required. After enabling the Bootstrap 4 library, add custom HTML to trigger and display modal overlays in your Content Templates and Views. You can place this code in a custom HTML block or in a separate Content Template, then embed that template with the Content Template block. Here is the HTML for an example modal, including the post title in the modal header and the post content and a simple custom field in the modal body:
<!-- Movie modal trigger button -->
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#movieModal-[wpv-post-id]">
View More
</button>
<!-- Movie modal -->
<div class="modal" tabindex="-1" id="movieModal-[wpv-post-id]" aria-labelledby="movieModalLabel-[wpv-post-id]" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<!-- Movie modal header -->
<div class="modal-header">
<h5 class="modal-title" id="movieModalLabel-[wpv-post-id]">[wpv-post-title]</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">x</span>
</button>
</div>
<!-- Movie modal body -->
<div class="modal-body">
<!-- modal body showing the main post content and a simple custom field -->
[wpv-post-body view_template="None"]<br />
[types field="my-field-slug"][/types]
</div>
<!-- Movie modal footer -->
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
If you place this code in a custom HTML block in your View's loop, a modal will be generated for each item in the loop and a button will be displayed to open the corresponding modal. Notice I have used the wpv-post-id shortcode in the modal structure to create dynamic, unique IDs for each modal in the loop of results. Dynamic IDs are necessary to connect the triggers and modals for each item in the results. You can modify this example code to include your Toolset Types custom fields and other content using our shortcode library.
Problem: I have placed a View in one of my BB Themer designs. When I activate this element in BB Themer, the page layout is broken.
Solution: Limit the use of Loop Templates in Views and other implementations of Content Templates when using 3rd-party templating systems like BB Themer, Elementor, etc. Content Templates often conflict with these other 3rd-party templating systems, so if you replace the Loop Template shortcode (wpv-post-body) in the loop of a View with the contents of that template, you can avoid this compatibility issue. See the screenshots below for more details about this.