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 13 topics - 5,956 through 5,968 (of 5,968 total)
Problem:
How to add a conditional test for the length of the value of a custom field.
Solution:
Register a custom shortcode to get the length of a field passed as an attribute for the current post by adding the following to your theme's functions.php:
/**
* Register shortcode "fieldlength"
*
* requires attribute field = "slug" of field to measure length of
*/
add_shortcode( 'fieldlength', function( $atts ){
global $post;
$string = get_post_meta( $post->ID, $atts['field'], true);
return strlen( $string );
});
Register the custom shortcode at Toolset > Settings > Front-end Content and then use it inside a wpv-conditional shortcode like so:
Problem: I have a View that returns some text. I would like to use the output of that View in a conditional statement on another part of my site. I have already added the raw output PHP filter, and the output contains the correct text if I display the View on the front-end. However, the conditional still fails because of empty space in the View's output.
Solution: Be sure to remove all unnecessary empty space in the Loop Output editor of your View. The code should appear with no line breaks like this: