{"id":2603,"date":"2017-11-24T03:35:54","date_gmt":"2017-11-24T03:35:54","guid":{"rendered":"http:\/\/docs.contentviewspro.com\/?p=2603"},"modified":"2023-12-27T11:10:00","modified_gmt":"2023-12-27T11:10:00","password":"","slug":"add-custom-text-html-etc-title-thumbnail-content-meta-fields-custom-fields","status":"publish","type":"docs","link":"https:\/\/contentviewspro.com\/documentation\/article\/add-custom-text-html-etc-title-thumbnail-content-meta-fields-custom-fields\/","title":{"rendered":"Add custom text, HTML before\/after the Title, Thumbnail, Content, Meta Fields&#8230;"},"content":{"rendered":"<p>Content Views Pro helps you to show the Title, Thumbnail image, Content, Meta Fields, Custom Fields of any WordPress posts easily.<br \/>\nYou might want to show dynamic, custom info before (or after) one of these fields. To do that, please add this code to file <strong>functions.php<\/strong> in the theme&#8217;s folder:<\/p>\n<pre style=\"font-size:13px\">\n\/**\n * Add extra info before\/after the field.\n * <strong>@TODO:<\/strong> Remove any line below if you don't need\n *\/\nadd_filter( 'pt_cv_item_title', 'cvp_theme_custom_content_to_field', 10, 2 );\nadd_filter( 'pt_cv_item_thumbnail', 'cvp_theme_custom_content_to_field', 10, 2 );\nadd_filter( 'pt_cv_item_content', 'cvp_theme_custom_content_to_field', 10, 2 );\nadd_filter( 'pt_cv_item_meta-fields', 'cvp_theme_custom_content_to_field', 10, 2 );\nadd_filter( 'pt_cv_item_custom-fields', 'cvp_theme_custom_content_to_field', 10, 2 );\n\n\/**\n * The function to add extra content to before (or after) above field\n * @param string $html\n * @param object $post\n * @return string\n *\/\nfunction cvp_theme_custom_content_to_field( $html, $post ) {\n\n\t$position = 'after'; \/\/ or 'before' the field\n\n\tob_start();\n\t\/\/<strong> @TODO:<\/strong> Add text, HTML, PHP code (access current post ID by <strong>$post-&gt;ID<\/strong>)\n\n\t$extra = ob_get_clean();\n\tif ( $position === 'after' ) {\n\t\t$html .= $extra;\n\t} else {\n\t\t$html = $extra . $html;\n\t}\n\n\treturn $html;\n}\n<\/pre>\n<p><strong>Notice 1<\/strong>: This task requires your coding skills about PHP, HTML.<\/p>\n<p><strong>Notice 2<\/strong>: If you want to apply above code to specific view only, below this line:<\/p>\n<pre style=\"font-size:13px\">\nfunction cvp_theme_custom_content_to_field( $html, $post ) {\n<\/pre>\n<p>please add this line:<\/p>\n<pre style=\"font-size:13px\">\nglobal $pt_cv_id; if ( $pt_cv_id !== 'VIEW_ID' ) { return $html; }\n<\/pre>\n<p>and replace <strong>VIEW_ID<\/strong> with <a href=\"https:\/\/contentviewspro.com\/documentation\/article\/what-is-id-of-a-view\/\">ID of your View<\/a>.<\/p>\n<p>Best regards,<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Content Views Pro helps you to show the Title, Thumbnail image, Content, Meta Fields, Custom Fields of any WordPress posts easily. You might want to show dynamic, custom info before (or after) one of these fields. To do that, please add this code to file functions.php in the theme&#8217;s folder: \/** * Add extra info &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"\" href=\"https:\/\/contentviewspro.com\/documentation\/article\/add-custom-text-html-etc-title-thumbnail-content-meta-fields-custom-fields\/\"> <span class=\"screen-reader-text\">Add custom text, HTML before\/after the Title, Thumbnail, Content, Meta Fields&#8230;<\/span> Read More &raquo;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"site-sidebar-layout":"default","site-content-layout":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","footnotes":""},"doc_category":[55],"doc_tag":[21],"class_list":["post-2603","docs","type-docs","status-publish","hentry","doc_category-advanced-modification","doc_tag-custom-code"],"year_month":"2026-09","word_count":254,"total_views":"6","reactions":{"happy":"0","normal":"0","sad":"0"},"author_info":{"name":"CVP","author_nicename":"cvp","author_url":"https:\/\/contentviewspro.com\/documentation\/author\/cvp\/"},"doc_category_info":[{"term_name":"Advanced Modification","term_url":"https:\/\/contentviewspro.com\/documentation\/cats\/advanced-modification\/"}],"doc_tag_info":[{"term_name":"custom PHP code","term_url":"https:\/\/contentviewspro.com\/documentation\/tags\/custom-code\/"}],"_links":{"self":[{"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/docs\/2603","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/comments?post=2603"}],"version-history":[{"count":1,"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/docs\/2603\/revisions"}],"predecessor-version":[{"id":5380,"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/docs\/2603\/revisions\/5380"}],"wp:attachment":[{"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/media?parent=2603"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/doc_category?post=2603"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/doc_tag?post=2603"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}