With the Views plugin you can create different Views elements to display all your custom types and content on the front-end, without coding. You can also create powerful parametric searches and add pagination to your content lists.
When you ask for help or report issues, make sure to tell us the options of your View.
Viewing 15 topics - 1,516 through 1,530 (of 1,560 total)
Problem:
The user wanted to display the last commented posts.
Solution:
As you can see in the WordPress database structure, comments are stored in another table than the one for posts. Currently, Toolset does not query/create/update/delete comments. It only acts on the posts and taxonomies tables. https://codex.wordpress.org/Database_Description
There are no shortcodes that will allow you to pull the comments data, either directly, or from posts on a view's query.
I actually did not test the solution, I have suggested on that ticket. You may be right, and "comment_post" is probably not the best hook to use. "transition_comment_status" seems to be a good candidate. This pseudo-code may help:
// update post last comment field when a comment is approved
function update_last_comment_field( $new_status, $old_status, $comment ) {
// Only when the status is approved.
if( 1 === $new_status ){
// get the post ID
$post_id = $comment->comment_post_ID ;
// get the post object
$post = get_post( $post_id );
// only for post type "post"
if ( $post->post_ype == "post" ) {
// update custom field. Toolset field slug is prefixed with "wpcf-"
update_post_meta( $post_id, 'wpcf-last-comment-time', time() );
}
}
}
Problem:
The user is following this tutorial to create a comparison page https://www.youtube.com/watch?v=oSuY4QF812s
When he selects more than 2 posts, the view works as expected. When he selected one post or none, the view displays all the posts.
Solution:
We'll need to implement a custom code that will check how many posts are passed to the comparison page. Then we can conditionally display the comparison view or a message.
This a sample code for the shortcode:
The shortcode needs to be registered in Toolset->Settings->Front-end Content to be used in conditions.
Then we can display a view or a message, like this:
[wpv-conditional if="( [wpv-search-term param='post_ids'] ne '' )"][wpv-view name="scholen-vergelijken-po"][/wpv-conditional]
[wpv-conditional if="( [wpv-search-term param='post_ids'] ne '' )" evaluate="false"]You will need to select at least two posts to compare[/wpv-conditional]
But i need made lesson 'private' (only teacher can view) by checkbox.
For example i have 10 lesson but one lesson as private - i check in checkbox "for teacher" and when guest or other user role show lesson archive they see 9 lesson, private lesson not shown.
Solution:
You might consider other workaround, for example, create another post type "Teacher only lessons", use Access to setup the limitation to this post type, so other user role won't be able to access posts of post type "Teacher only lessons".