Change comments count text

Content Views helps you to show comments count of WordPress posts easily without coding. By default, Content Views uses the default WordPress comment counting function.

If you want to change comments count text, please add this code to file functions.php of your WordPress theme:

// Content Views - customize comments count output
add_filter( 'pt_cv_comments_count', 'cvp_theme_comments_count', 100, 1 );
function cvp_theme_comments_count( $args ) {
	ob_start();
	comments_popup_link( 'No Comments', '1 Comment', '% Comments' );
	$args = ob_get_clean();
	return $args;
}

You can modify ‘No Comments’, ‘1 Comment’, ‘% Comments’ as you want.

This is available for both Free & Pro version of Content Views (since free version 1.9.9.2).

Thank you,

Shuffle Filter – show Dropdown options in 2 columns

If you have a lot of options, it will be friendly to show options in 2 columns, to help visitors to select filters without scrolling too much.
To do it, please add this code to Custom CSS field in Content Views >> Settings page:

.pt-cv-wrapper [id^="pt-cv-filter-bar-VIEWID"] >.dropdown-menu {min-width:400px}
.pt-cv-wrapper [id^="pt-cv-filter-bar-VIEWID"] ul.dropdown-menu li {width:48%!important;display:inline-block}

(replace VIEWID with ID of your View).

To make it works with ALL dropdown filters, please use this code instead:

div.pt-cv-wrapper .pt-cv-filter-bar >.dropdown-menu {min-width:400px}
div.pt-cv-wrapper .pt-cv-filter-bar ul.dropdown-menu li {width:48%!important;display:inline-block}

Best regards,

How to add “NEW” icon after recent post title?

You might want to show a “NEW” icon after your latest posts’ title.
Please add this code to file functions.php of your active theme:

// Content Views Pro - Show custom icon in title
add_filter( 'pt_cv_field_title_result', 'cvp_theme_title_new_icon', 100, 3 );
function cvp_theme_title_new_icon( $title, $fargs, $post ) {
	$hours	 = 24; /* TODO: change this value to number of hours to calculate */
	$diff	 = time() - mysql2date( 'U', $post->post_date );

	if ( $hours * 60 * 60 > $diff ) {		
		// 1. To show a "New" icon/image, remove the 2. below
		$title = $title . "<img src='IMAGE_URL_HERE' />";
		
		// 2. To show a "New" text, remove the 1. above
		$title = $title . "<span style='padding:2px 8px;color:#fff;background:red;margin-left:5px;'>New</span>";
	}

	return $title;
}

Thank you,

How does Content Views Pro get the thumbnail?

With Content Views Pro, you can show featured image, image/video/audio in post content, image custom field as thumbnail. Here is how:

  • By default, Content Views Pro (CVP) will look for the featured image.
  • If no featured image found (or if you select CVP setting which forces to replace featured image), CVP will look for image/video/audio URL in post content (how to insert image/video/audio URL).
    If one of these things found, it will be shown as thumbnail (see demo).
  • If nothing found, CVP will display a default image (how to replace default image by your image).
  • Also, You can show an image custom field as thumbnail (read document).

Best regards,

Display posts right to left (RTL)

Content Views helps you to show posts easily. Normally, posts are displayed from left to right.
To display posts from right to left in Grid layout, please add this custom CSS:

#pt-cv-view-VIEWID .pt-cv-content-item {
    float: right !important;
}

(Please replace VIEWID with ID of your View)

Best regards,

Add new social share buttons (WhatsApp, Tumblr, Parler, Email)

Content Views Pro helps you to show social share buttons easily. By default, you show sharing buttons of Facebook, Twitter, Google +, Linkedin, Pinterest.
To add more social share buttons, please:

  • enable “Social Sharing” in the “Display Settings” tab of the View
    Content Views Pro - social sharing
  • add this code to file functions.php of your active theme:
    // Content Views Pro - Add new social buttons
    add_filter( 'pt_cv_social_links', 'cvp_theme_social_links', 100, 3 );
    function cvp_theme_social_links( $buttons_html, $url, $title ) {
    	### whatsapp ###
    	$social_link	 = sprintf( 'whatsapp://send?text=%s', $url );
    	$buttons_html[]	 = sprintf( '<a href="%s" class="%s" target="_blank"></a>', $social_link, esc_attr( 'pt-cv-social-whatsapp' ) );
    
    	### tumblr ###
    	$social_link	 = sprintf( 'http://www.tumblr.com/share/link?url=%s', $url );
    	$buttons_html[]	 = sprintf( '<a href="%s" class="%s" target="_blank"></a>', $social_link, esc_attr( 'pt-cv-social-tumblr' ) );
    
    	### parler ###
    	$social_link	 = sprintf( 'https://parler.com/new-post?message=Check%20this%20out&url=%s', $url );
    	$buttons_html[]	 = sprintf( '<a href="%s" class="%s" target="_blank"></a>', $social_link, esc_attr( 'pt-cv-social-parler' ) );
    
    	### email ###
    	$email_link	 = sprintf( 'mailto:?subject=%s&body=%s', 'Hello, check this post', str_replace( array( ' ', '+' ), '%20', $title ) . ": $url" );
    	$buttons_html[]	 = sprintf( '<a href="%s" class="%s" target="_blank"></a>', $email_link, esc_attr( 'pt-cv-social-email' ) );
    
    	return $buttons_html;
    }
    
  • add this code to Custom CSS field in Content Views >> Settings page:
    .pt-cv-social-whatsapp {
        background: url(https://i.imgur.com/hsCmozv.png) no-repeat !important;
        background-size: 32px !important;
    }
    
    .pt-cv-social-tumblr {
        background: url(https://i.imgur.com/xvNm4pF.png) no-repeat !important;
        background-size: 32px !important;
    }
    
    .pt-cv-social-email {
        background: url(https://i.imgur.com/7NC5NQP.png) no-repeat !important;
        background-size: 32px !important;
    }
    
    .pt-cv-social-parler {
        background: url(https://i.imgur.com/ajMOaUw.png) no-repeat !important;
        background-size: 32px !important;
    }
    

Notice:
If you are using another plugin to add social buttons to your site, you might integrate that plugin to grid/list View using the code here (see document).
The code for // Put the text, HTML or PHP code here is the PHP function (or shortcode) to shows social buttons for a post of the social plugin (you might contact their support to know that function).

Best regards,

Show custom field image as thumbnail

Content Views Pro version 5.5.0 and higher

Since Content Views Pro version 5.5.0, you can easily show image custom field as thumbnail without coding.

Here is the configuration in Display Settings >> Fields Settings >> Thumbnail of the View to show any image custom field as thumbnail:

Content Views Pro version 5.4.1 and prior

For previous Pro versions, to show the custom field as thumbnail, please follow steps below:

  • In the View where you want to show the custom field as thumbnail, select the Show Thumbnail checkbox in Display Settings >> Fields settings.
  • Under Display Settings >> Fields settings >> Thumbnail >> Substitute, please configure as below:
    CVP - show custom field as thumbnail
  • Add this code to file functions.php of your active theme:
    // Content Views Pro - Use custom field as thumbnail
    add_filter( 'pt_cv_field_content_excerpt', 'cvp_theme_custom_field_as_thumbnail', 999, 3 );
    function cvp_theme_custom_field_as_thumbnail( $args, $fargs, $post ) {
    	if ( empty( $fargs ) ) {
    		$custom_field = 'CUSTOM_FIELD';
    
    		$fval = null;
    		if ( class_exists( 'CVP_CTF' ) ) {
    			$ctf = new CVP_CTF( $custom_field, $post, true, '' );
    			if ( !empty( $ctf->field_value ) ) {
    				$fval = $ctf->field_value;
    			}
    		}
    
    		if ( empty( $fval ) ) {
    			$meta = get_post_meta( $post->ID );
    			if ( !empty( $meta[ $custom_field ][ 0 ] ) ) {
    				$fval = $meta[ $custom_field ][ 0 ];
    			}
    		}
    
    		if ( $fval ) {
    			$args = sprintf( "<img src='%s'>", $fval );
    		}
    	}
    
    	return $args;
    }
    

    (replace CUSTOM_FIELD with slug/key of your custom field).

Notice: If you created custom field with Toolset plugin, you may need to add prefix wpcf-. For example, you created a custom field post-image with Toolset plugin, then the value of CUSTOM_FIELD should be wpcf-post-image.

Thank you,

Filter posts by Status

Content Views helps you to filter posts, pages easily. By default, it will show only published items.
How to show scheduled, pending (or other statuses) items?
You can do it easily with 2 simple steps:

  • select the Status checkbox in Filter Settings >> Advance
  • select the statuses you want to filter

Content Views - filter by status

Best regards,

Show multilingual posts with WPML, Polylang plugin

This feature is only available in the Pro version.

Content Views Pro will help you to show posts in all languages by WPML (or Polylang) plugin in your WordPress site easily.
You only need to create one View to show content in ALL languages.

For example, your content is available in 3 languages: English (default), Spanish, Russian. And you want to show some posts in an English page (this page has translation pages in Spanish, Russian).

Please do simple steps below:

  • Click Content Views > Add New to add new View, or edit an existing View
  • In admin toolbar at top of the page, switch to the default language:
    WPML - Change language in admin
    (mouse over the language bar, click the default language)

    For WordPress.com Business users, the WPML language bar (until version 4.0.6) doesn’t show at top. To switch to the default language, please append
    &language=CODE
    to the end of current URL, then press Enter.
    With CODE is the code of default language in the WPML languages table.

  • Adjust View settings to filter and show posts in your desired way
  • Save the View
  • Paste the View shortcode to the page of the default language, and all of its translation pages.

Thank you,