{"id":2460,"date":"2021-12-30T15:50:17","date_gmt":"2021-12-30T07:50:17","guid":{"rendered":"https:\/\/www.intelliwolf.com\/?p=2460"},"modified":"2022-04-11T14:06:42","modified_gmt":"2022-04-11T06:06:42","slug":"add-text-to-every-post-astra","status":"publish","type":"post","link":"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/add-text-to-every-post-astra\/","title":{"rendered":"How To Display A Message On Every Post In WordPress Astra"},"content":{"rendered":"\n

I had a request from a reader for a tutorial on how to add a message to every post, but not to archives, categories or the blogroll.<\/p>\n\n\n\n

Specifically, they wanted an affiliate disclaimer to appear on every post, below the post title. They were using the Astra theme<\/a>.<\/p>\n\n\n\n

\"Example<\/figure><\/div>\n\n\n\n

But they didn't want the affiliate disclaimer to appear on the post preview on category etc pages.<\/p>\n\n\n\n

\"Example<\/figure><\/div>\n\n\n\n

How to add text to every post on WordPress Astra<\/h2>\n\n\n\n

Create a function that hooks into the place in the post you want the text to appear. Use if( is_single() ) {}<\/em> to only display the text on single posts.<\/p>\n\n\n\n

Because I wanted the text to display before the content, but under the post title, the code I used is:<\/p>\n\n\n\n

add_action( 'astra_entry_content_before', 'display_disclaimer' );\n\nfunction display_disclaimer() {\n  if( is_single() ) {\n    echo \"<p><em>This is a disclaimer<\/em><\/p>\";\n  }\n}<\/code><\/pre>\n\n\n\n

Add this code to the functions.php<\/em> file of your child theme<\/a>.<\/p>\n\n\n\n

But what if you wanted to do the opposite?<\/p>\n\n\n\n

How to add text on the category page for every post using WordPress Astra<\/h2>\n\n\n\n

Create a function that hooks into the place in the post you want the text to appear. Use if( is_archive() ) {}<\/em> to only display the text on the category pages. Or use if( !is_single() ) {}<\/em> to display the text everywhere that isn't a single post.<\/p>\n\n\n\n

The code is almost identical to above:<\/p>\n\n\n\n

add_action( 'astra_entry_content_before', 'display_disclaimer' );\n\nfunction display_disclaimer() {\n  if( is_archive() ) {\n    echo \"<p><em>This is a disclaimer<\/em><\/p>\";\n  }\n}<\/code><\/pre>\n\n\n\n

That will add the text to every post, but only on the category pages.<\/p>\n\n\n\n

\"Example<\/figure><\/div>\n\n\n\n

<\/p>\n","protected":false},"excerpt":{"rendered":"

I had a request from a reader for a tutorial on how to add a message to every post, but not to archives, categories or the blogroll. Specifically, they wanted an affiliate disclaimer to appear on every post, below the post title. They were using the Astra theme. But they didn’t want the affiliate disclaimer<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[19],"yoast_head":"\nHow To Display A Message On Every Post In WordPress Astra<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.intelliwolf.com\/add-text-to-every-post-astra\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How To Display A Message On Every Post In WordPress Astra\" \/>\n<meta property=\"og:description\" content=\"I had a request from a reader for a tutorial on how to add a message to every post, but not to archives, categories or the blogroll. Specifically, they wanted an affiliate disclaimer to appear on every post, below the post title. They were using the Astra theme. But they didn't want the affiliate disclaimer\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.intelliwolf.com\/add-text-to-every-post-astra\/\" \/>\n<meta property=\"og:site_name\" content=\"Intelliwolf\" \/>\n<meta property=\"article:published_time\" content=\"2021-12-30T07:50:17+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-04-11T06:06:42+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/intelliwolf.com\/wp-content\/uploads\/2021\/12\/2021-12-30-add-message-every-astra-post-01-600x299.png\" \/>\n<meta name=\"author\" content=\"Mike Haydon\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Mike Haydon\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.intelliwolf.com\/add-text-to-every-post-astra\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.intelliwolf.com\/add-text-to-every-post-astra\/\"},\"author\":{\"name\":\"Mike Haydon\",\"@id\":\"https:\/\/www.intelliwolf.com\/#\/schema\/person\/7209e3ff14822e4d70d5f194a310f343\"},\"headline\":\"How To Display A Message On Every Post In WordPress Astra\",\"datePublished\":\"2021-12-30T07:50:17+00:00\",\"dateModified\":\"2022-04-11T06:06:42+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.intelliwolf.com\/add-text-to-every-post-astra\/\"},\"wordCount\":236,\"commentCount\":7,\"publisher\":{\"@id\":\"https:\/\/www.intelliwolf.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.intelliwolf.com\/add-text-to-every-post-astra\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/intelliwolf.com\/wp-content\/uploads\/2021\/12\/2021-12-30-add-message-every-astra-post-01-600x299.png\",\"keywords\":[\"Astra\"],\"articleSection\":[\"Theme Customization\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.intelliwolf.com\/add-text-to-every-post-astra\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.intelliwolf.com\/add-text-to-every-post-astra\/\",\"url\":\"https:\/\/www.intelliwolf.com\/add-text-to-every-post-astra\/\",\"name\":\"How To Display A Message On Every Post In WordPress Astra\",\"isPartOf\":{\"@id\":\"https:\/\/www.intelliwolf.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.intelliwolf.com\/add-text-to-every-post-astra\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.intelliwolf.com\/add-text-to-every-post-astra\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/intelliwolf.com\/wp-content\/uploads\/2021\/12\/2021-12-30-add-message-every-astra-post-01-600x299.png\",\"datePublished\":\"2021-12-30T07:50:17+00:00\",\"dateModified\":\"2022-04-11T06:06:42+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.intelliwolf.com\/add-text-to-every-post-astra\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.intelliwolf.com\/add-text-to-every-post-astra\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.intelliwolf.com\/add-text-to-every-post-astra\/#primaryimage\",\"url\":\"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-content\/uploads\/2021\/12\/2021-12-30-add-message-every-astra-post-01.png\",\"contentUrl\":\"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-content\/uploads\/2021\/12\/2021-12-30-add-message-every-astra-post-01.png\",\"width\":690,\"height\":344},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.intelliwolf.com\/add-text-to-every-post-astra\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.intelliwolf.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Theme Customization\",\"item\":\"https:\/\/www.intelliwolf.com\/category\/theme-customization\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"How To Display A Message On Every Post In WordPress Astra\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.intelliwolf.com\/#website\",\"url\":\"https:\/\/www.intelliwolf.com\/\",\"name\":\"Intelliwolf\",\"description\":\"WordPress, Web Design and Coding Tutorials\",\"publisher\":{\"@id\":\"https:\/\/www.intelliwolf.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.intelliwolf.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.intelliwolf.com\/#organization\",\"name\":\"Intelliwolf\",\"url\":\"https:\/\/www.intelliwolf.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.intelliwolf.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-content\/uploads\/intelliwolf-logo-300t.png\",\"contentUrl\":\"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-content\/uploads\/intelliwolf-logo-300t.png\",\"width\":300,\"height\":100,\"caption\":\"Intelliwolf\"},\"image\":{\"@id\":\"https:\/\/www.intelliwolf.com\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.intelliwolf.com\/#\/schema\/person\/7209e3ff14822e4d70d5f194a310f343\",\"name\":\"Mike Haydon\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.intelliwolf.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/d5f4754fae310a04dede91d15e57c8a0?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/d5f4754fae310a04dede91d15e57c8a0?s=96&d=mm&r=g\",\"caption\":\"Mike Haydon\"},\"sameAs\":[\"https:\/\/intelliwolf.com\/about-mike-haydon\/\"]}]}<\/script>\n","yoast_head_json":{"title":"How To Display A Message On Every Post In WordPress Astra","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.intelliwolf.com\/add-text-to-every-post-astra\/","og_locale":"en_US","og_type":"article","og_title":"How To Display A Message On Every Post In WordPress Astra","og_description":"I had a request from a reader for a tutorial on how to add a message to every post, but not to archives, categories or the blogroll. Specifically, they wanted an affiliate disclaimer to appear on every post, below the post title. They were using the Astra theme. But they didn't want the affiliate disclaimer","og_url":"https:\/\/www.intelliwolf.com\/add-text-to-every-post-astra\/","og_site_name":"Intelliwolf","article_published_time":"2021-12-30T07:50:17+00:00","article_modified_time":"2022-04-11T06:06:42+00:00","og_image":[{"url":"https:\/\/intelliwolf.com\/wp-content\/uploads\/2021\/12\/2021-12-30-add-message-every-astra-post-01-600x299.png"}],"author":"Mike Haydon","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Mike Haydon","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.intelliwolf.com\/add-text-to-every-post-astra\/#article","isPartOf":{"@id":"https:\/\/www.intelliwolf.com\/add-text-to-every-post-astra\/"},"author":{"name":"Mike Haydon","@id":"https:\/\/www.intelliwolf.com\/#\/schema\/person\/7209e3ff14822e4d70d5f194a310f343"},"headline":"How To Display A Message On Every Post In WordPress Astra","datePublished":"2021-12-30T07:50:17+00:00","dateModified":"2022-04-11T06:06:42+00:00","mainEntityOfPage":{"@id":"https:\/\/www.intelliwolf.com\/add-text-to-every-post-astra\/"},"wordCount":236,"commentCount":7,"publisher":{"@id":"https:\/\/www.intelliwolf.com\/#organization"},"image":{"@id":"https:\/\/www.intelliwolf.com\/add-text-to-every-post-astra\/#primaryimage"},"thumbnailUrl":"https:\/\/intelliwolf.com\/wp-content\/uploads\/2021\/12\/2021-12-30-add-message-every-astra-post-01-600x299.png","keywords":["Astra"],"articleSection":["Theme Customization"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.intelliwolf.com\/add-text-to-every-post-astra\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.intelliwolf.com\/add-text-to-every-post-astra\/","url":"https:\/\/www.intelliwolf.com\/add-text-to-every-post-astra\/","name":"How To Display A Message On Every Post In WordPress Astra","isPartOf":{"@id":"https:\/\/www.intelliwolf.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.intelliwolf.com\/add-text-to-every-post-astra\/#primaryimage"},"image":{"@id":"https:\/\/www.intelliwolf.com\/add-text-to-every-post-astra\/#primaryimage"},"thumbnailUrl":"https:\/\/intelliwolf.com\/wp-content\/uploads\/2021\/12\/2021-12-30-add-message-every-astra-post-01-600x299.png","datePublished":"2021-12-30T07:50:17+00:00","dateModified":"2022-04-11T06:06:42+00:00","breadcrumb":{"@id":"https:\/\/www.intelliwolf.com\/add-text-to-every-post-astra\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.intelliwolf.com\/add-text-to-every-post-astra\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.intelliwolf.com\/add-text-to-every-post-astra\/#primaryimage","url":"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-content\/uploads\/2021\/12\/2021-12-30-add-message-every-astra-post-01.png","contentUrl":"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-content\/uploads\/2021\/12\/2021-12-30-add-message-every-astra-post-01.png","width":690,"height":344},{"@type":"BreadcrumbList","@id":"https:\/\/www.intelliwolf.com\/add-text-to-every-post-astra\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.intelliwolf.com\/"},{"@type":"ListItem","position":2,"name":"Theme Customization","item":"https:\/\/www.intelliwolf.com\/category\/theme-customization\/"},{"@type":"ListItem","position":3,"name":"How To Display A Message On Every Post In WordPress Astra"}]},{"@type":"WebSite","@id":"https:\/\/www.intelliwolf.com\/#website","url":"https:\/\/www.intelliwolf.com\/","name":"Intelliwolf","description":"WordPress, Web Design and Coding Tutorials","publisher":{"@id":"https:\/\/www.intelliwolf.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.intelliwolf.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.intelliwolf.com\/#organization","name":"Intelliwolf","url":"https:\/\/www.intelliwolf.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.intelliwolf.com\/#\/schema\/logo\/image\/","url":"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-content\/uploads\/intelliwolf-logo-300t.png","contentUrl":"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-content\/uploads\/intelliwolf-logo-300t.png","width":300,"height":100,"caption":"Intelliwolf"},"image":{"@id":"https:\/\/www.intelliwolf.com\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.intelliwolf.com\/#\/schema\/person\/7209e3ff14822e4d70d5f194a310f343","name":"Mike Haydon","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.intelliwolf.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/d5f4754fae310a04dede91d15e57c8a0?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d5f4754fae310a04dede91d15e57c8a0?s=96&d=mm&r=g","caption":"Mike Haydon"},"sameAs":["https:\/\/intelliwolf.com\/about-mike-haydon\/"]}]}},"_links":{"self":[{"href":"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-json\/wp\/v2\/posts\/2460"}],"collection":[{"href":"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-json\/wp\/v2\/comments?post=2460"}],"version-history":[{"count":2,"href":"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-json\/wp\/v2\/posts\/2460\/revisions"}],"predecessor-version":[{"id":2465,"href":"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-json\/wp\/v2\/posts\/2460\/revisions\/2465"}],"wp:attachment":[{"href":"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-json\/wp\/v2\/media?parent=2460"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-json\/wp\/v2\/categories?post=2460"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-json\/wp\/v2\/tags?post=2460"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}