{"id":3196,"date":"2018-07-04T02:08:54","date_gmt":"2018-07-04T02:08:54","guid":{"rendered":"https:\/\/docs.contentviewspro.com\/?p=3196"},"modified":"2018-07-04T02:08:54","modified_gmt":"2018-07-04T02:08:54","password":"","slug":"add-title-attribute-links","status":"publish","type":"docs","link":"https:\/\/contentviewspro.com\/documentation\/article\/add-title-attribute-links\/","title":{"rendered":"Add &#8220;title&#8221; attribute to links"},"content":{"rendered":"<p>For SEO purposes, many researches state that title attribute might not be given much weight in ranking.<br \/>\nFor user&#8217;s experience, the title attribute can provide descriptive text (or supplementary information) to the link.<\/p>\n<p>To add title attribute to links in grid or list of Content Views, please add this code to file <strong>functions.php<\/strong> in the theme&#8217;s folder (or install this plugin <a href=\"https:\/\/wordpress.org\/plugins\/code-snippets\/\" rel=\"nofollow\">Code Snippets<\/a> then add this code to <a href=\"https:\/\/ps.w.org\/code-snippets\/assets\/screenshot-2.png\" rel=\"nofollow\">the &#8220;Code&#8221; textarea<\/a>):<\/p>\n<pre style=\"font-size:13px\">\n\/\/ Content Views Pro - add Title attribute to images\nadd_filter( 'wp_get_attachment_image_attributes', 'cv_add_tilte_for_image', 100, 3 );\nfunction cv_add_tilte_for_image( $attr, $attachment, $size ) {\n\tglobal $cvp_process_settings;\n\tif ( $cvp_process_settings ) {\n\t\tglobal $post;\n\t\t\/\/ Get title of featured image first, then get the title of post\n\t\t$title\t\t\t = isset( $attachment->post_title ) ? $attachment->post_title : (isset( $post->post_title ) ? $post->post_title : '');\n\t\t$attr[ 'title' ] = esc_attr( $title );\n\t}\n\treturn $attr;\n}\n\n\/\/ Content Views Pro - add Title attribute to links\nadd_filter( 'pt_cv_field_href_attrs', 'cvp_theme_add_title_to_links', 100, 3 );\nfunction cvp_theme_add_title_to_links( $custom_attr, $open_in, $oargs = array() ) {\n\tglobal $post;\n\tif ( isset( $post->post_title ) ) {\n\t\t$custom_attr[] = 'title=\"' . esc_attr( $post->post_title ) . '\"';\n\t}\n\treturn $custom_attr;\n}\n\n<\/pre>\n<p>Best regards,<\/p>\n","protected":false},"excerpt":{"rendered":"<p>For SEO purposes, many researches state that title attribute might not be given much weight in ranking. For user&#8217;s experience, the title attribute can provide descriptive text (or supplementary information) to the link. To add title attribute to links in grid or list of Content Views, please add this code to file functions.php in the &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"\" href=\"https:\/\/contentviewspro.com\/documentation\/article\/add-title-attribute-links\/\"> <span class=\"screen-reader-text\">Add &#8220;title&#8221; attribute to links<\/span> Read More &raquo;<\/a><\/p>\n","protected":false},"author":1,"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":[25],"doc_tag":[21],"class_list":["post-3196","docs","type-docs","status-publish","hentry","doc_category-adjustment","doc_tag-custom-code"],"year_month":"2026-09","word_count":205,"total_views":"5","reactions":{"happy":"0","normal":"0","sad":"0"},"author_info":{"name":"admin1","author_nicename":"admin1","author_url":"https:\/\/contentviewspro.com\/documentation\/author\/admin1\/"},"doc_category_info":[{"term_name":"Adjustment","term_url":"https:\/\/contentviewspro.com\/documentation\/cats\/adjustment\/"}],"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\/3196","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\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/comments?post=3196"}],"version-history":[{"count":0,"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/docs\/3196\/revisions"}],"wp:attachment":[{"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/media?parent=3196"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/doc_category?post=3196"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/doc_tag?post=3196"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}