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 More

Display 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 More

Get 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 More

Conditional 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 More

Views 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 More