Views
Conditional output if post body is empty
There is a bug in views related to conditional output based on post content so this is a work around. In themes functions file: // Views test for post content add_shortcode ( ‘wpv-post-getcontent’, ‘wpv_getcontent’ ); function wpv_getcontent() { global $post; if(get_the_content() != ”) : return 1; else : return 0; endif; wp_reset_query(); } Then in…
Read MoreUse blog_info data in Views
For instance to show blog_info(‘url’) field in a view: [wpv-bloginfo show=’url’]
Read MoreConditional Featured Image Present
To show the featured image if it is present: [wpv-if image=”_thumbnail_id” evaluate=”!empty($image)”] [wpv-post-featured-image size=”full”] [/wpv-if]
Read MoreDisplay Sibling Posts using WP Views
This is based on this tutorial: http://wp-types.com/documentation/user-guides/displaying-brother-pages/ But I couldn’t get it working until by trial and error I found that the following worked: Create a View that pulls the child post using the filter “Select related posts that are a child of the post set by the parent view.” eg: “Further Works by Artist”…
Read MoreGet Link to Featured Image for use in View
In functions.php create function and shortcode /** *************************************************** * get image src for featured image of post (large version) */ /* Register our short code at the appropriate time during the WordPress Boot process. */ add_action( ‘init’, ‘wpk_register_shortcodes’); function wpk_register_shortcodes(){ add_shortcode(‘my_get_thumbsrc’, ‘my_get_thumbsrc’); } /* Function to return the source url for the featured image of…
Read MoreConditional Fields in View – show if not empty
Fields can be hidden if they are empty as follows: [wpv-if contact=”wpcf-contact” evaluate=”empty($contact)” condition=”false”] [types field=”contact” class=”” style=””][/types] [/wpv-if] Other conditional statements are detailed here: http://wp-types.com/documentation/user-guides/conditional-html-output-in-views/ Useful example to show value if the field is not empty or a “NULL” string [wpv-if framed=”wpcf-framed” evaluate=”($framed != ‘NULL’) AND (!empty($framed))”] DO SOMETHING HERE [/wpv-if]
Read MoreViews Featured Image Size
Specify featured image size using WP Views field: [wpv-post-featured-image size=”full”] Can define new image sizes in functions.php and use them for specific instances
Read MoreNo Posts Found Text Shortcode
Shows text within shortcode tags when no rows are returned by the view [wpv-no-posts-found]No posts found[/wpv-no-posts-found]
Read MoreViews using URL parameters for filters with spaces in the name
When using URL parameters to specify a filter use the Taxonomy name and use %20 in place of spaces. /12/latest-reviews/?wine=Sauvignon%20Blanc&vintage=2010
Read More