{"id":17399,"date":"2023-12-02T06:13:37","date_gmt":"2023-12-02T06:13:37","guid":{"rendered":"https:\/\/kwebby.com\/blog\/?p=17399"},"modified":"2023-12-13T10:14:44","modified_gmt":"2023-12-13T10:14:44","slug":"og-tags-wordpress-without-plugin","status":"publish","type":"post","link":"https:\/\/kwebby.com\/blog\/og-tags-wordpress-without-plugin\/","title":{"rendered":"How to add OG (Open Graph) tags in WordPress Without Plugin (Easy Way)"},"content":{"rendered":"\n<p>Optimizing your WordPress site for social media shares is crucial in today&#8217;s digital landscape, and one of the keys to this optimization is the proper implementation of <a href=\"https:\/\/ogp.me\/\" target=\"_blank\" data-type=\"link\" data-id=\"https:\/\/ogp.me\/\" rel=\"noreferrer noopener\">Open Graph (OG) tags<\/a>. These tags allow for a rich graphical representation of your media on social platforms, enhancing visibility and click-through rates.<\/p>\n\n\n\n<p>However, using a plugin may not always be the preferred or viable solution, especially when one considers the potential for slowing down your website or compatibility issues.<\/p>\n\n\n\n<p><a href=\"https:\/\/kwebby.com\/blog\/meta-tags-seo\/\">What Are Meta Tags? Is it Important for SEO? Let\u2019s Find Out !<\/a><\/p>\n\n\n\n<p>In this guide, we will walk you through a comprehensive, step-by-step process on how to add OG tags in WordPress without the reliance on a plugin, enabling you to boost your social media presence professionally and efficiently.<\/p>\n\n\n\n<p>Checkout Our Detailed guide, <a href=\"https:\/\/kwebby.com\/blog\/social-media-meta-tags\/\">Ultimate Guide to Generate Social Media Meta Tags for Your Website<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to Add Open Graph Tags in WordPress Without Plugin<\/h2>\n\n\n\n<iframe loading=\"lazy\" width=\"560\" height=\"315\" src=\"https:\/\/www.youtube.com\/embed\/O5f7CSfxKVI?si=oNxE4ytz4-hqEpvS\" title=\"YouTube video player\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" allowfullscreen><\/iframe>\n\n\n\n<p>Adding Open Graph (OG) tags to your WordPress site without a plugin might seem like an intimidating task, especially if you&#8217;re not deeply familiar with coding. But, what if we told you it&#8217;s not as hard as you think?<\/p>\n\n\n\n<p>Imagine having complete control over how your content is represented on social media platforms, enhancing its visibility, and driving more traffic to your site without the potential drawbacks of using a plugin.<\/p>\n\n\n\n<p>In the following sections, we will guide you through this process, demonstrating how you can implement OG tags seamlessly into your WordPress site.<\/p>\n\n\n\n<p>Let&#8217;s begin, shall we?<\/p>\n\n\n\n<p>First You need to copy the following code;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\n\/\/ Get the post\/page title\nif (is_singular()) {\n    $og_title = get_the_title();\n} else {\n    $og_title = get_bloginfo('name');\n}\n\n\/\/ Get the post\/page description\nif (is_singular()) {\n    $og_description = get_the_excerpt();\n} else {\n    $og_description = get_bloginfo('description');\n}\n\n\/\/ Get the featured image URL\nif (is_singular() &amp;&amp; has_post_thumbnail()) {\n    $og_image = get_the_post_thumbnail_url(null, 'large');\n} else {\n    $og_image = 'URL_to_Your_Default_Image'; \/\/ Replace with your default image URL\n}\n\n\/\/ Get the current URL\n$og_url = get_permalink();\n\n\/\/ Output the OG meta tags\n?&gt;\n&lt;meta property=\"og:title\" content=\"&lt;?php echo esc_attr($og_title); ?&gt;\"&gt;\n&lt;meta property=\"og:description\" content=\"&lt;?php echo esc_attr($og_description); ?&gt;\"&gt;\n&lt;meta property=\"og:image\" content=\"&lt;?php echo esc_url($og_image); ?&gt;\"&gt;\n&lt;meta property=\"og:url\" content=\"&lt;?php echo esc_url($og_url); ?&gt;\"&gt;\n&lt;meta property=\"og:type\" content=\"article\"&gt;\n&lt;meta property=\"og:site_name\" content=\"your_site_name\" \/&gt;<\/code><\/pre>\n\n\n\n<p>Edit the following property, replace &#8220;your_site_name&#8221; with your site name e.g. Kwebby;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;meta property=\"og:site_name\" content=\"your_site_name\" \/&gt;<\/code><\/pre>\n\n\n\n<p>Now, You need to open your WordPress dashboard, Go to Appearance &gt; Theme file editor;<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"804\" height=\"506\" src=\"https:\/\/kwebby.com\/blog\/wp-content\/uploads\/2023\/12\/theme-file-edit.png\" alt=\"\" class=\"wp-image-17401\" title=\"\" srcset=\"https:\/\/kwebby.com\/blog\/wp-content\/uploads\/2023\/12\/theme-file-edit.png 804w, https:\/\/kwebby.com\/blog\/wp-content\/uploads\/2023\/12\/theme-file-edit-300x189.png 300w, https:\/\/kwebby.com\/blog\/wp-content\/uploads\/2023\/12\/theme-file-edit-768x483.png 768w\" sizes=\"auto, (max-width: 804px) 100vw, 804px\" \/><\/figure>\n\n\n\n<p>Next, Verify if it&#8217;s your current theme as below;<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"776\" height=\"534\" src=\"https:\/\/kwebby.com\/blog\/wp-content\/uploads\/2023\/12\/verify-theme.png\" alt=\"\" class=\"wp-image-17402\" title=\"\" srcset=\"https:\/\/kwebby.com\/blog\/wp-content\/uploads\/2023\/12\/verify-theme.png 776w, https:\/\/kwebby.com\/blog\/wp-content\/uploads\/2023\/12\/verify-theme-300x206.png 300w, https:\/\/kwebby.com\/blog\/wp-content\/uploads\/2023\/12\/verify-theme-768x528.png 768w\" sizes=\"auto, (max-width: 776px) 100vw, 776px\" \/><\/figure>\n\n\n\n<p>Now, navigate to Header.php file from the theme files;<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"640\" src=\"https:\/\/kwebby.com\/blog\/wp-content\/uploads\/2023\/12\/theme-header-1024x640.png\" alt=\"\" class=\"wp-image-17403\" title=\"\" srcset=\"https:\/\/kwebby.com\/blog\/wp-content\/uploads\/2023\/12\/theme-header-1024x640.png 1024w, https:\/\/kwebby.com\/blog\/wp-content\/uploads\/2023\/12\/theme-header-300x188.png 300w, https:\/\/kwebby.com\/blog\/wp-content\/uploads\/2023\/12\/theme-header-768x480.png 768w, https:\/\/kwebby.com\/blog\/wp-content\/uploads\/2023\/12\/theme-header-1536x961.png 1536w, https:\/\/kwebby.com\/blog\/wp-content\/uploads\/2023\/12\/theme-header.png 1615w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Now your WordPress header file will open, you need to paste the copied code above after &lt;head&gt; or below &lt;meta&gt; section;<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"555\" src=\"https:\/\/kwebby.com\/blog\/wp-content\/uploads\/2023\/12\/paste-code-1024x555.png\" alt=\"\" class=\"wp-image-17404\" title=\"\" srcset=\"https:\/\/kwebby.com\/blog\/wp-content\/uploads\/2023\/12\/paste-code-1024x555.png 1024w, https:\/\/kwebby.com\/blog\/wp-content\/uploads\/2023\/12\/paste-code-300x163.png 300w, https:\/\/kwebby.com\/blog\/wp-content\/uploads\/2023\/12\/paste-code-768x416.png 768w, https:\/\/kwebby.com\/blog\/wp-content\/uploads\/2023\/12\/paste-code-1536x832.png 1536w, https:\/\/kwebby.com\/blog\/wp-content\/uploads\/2023\/12\/paste-code-2048x1110.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>After you paste it, click on the Update file button to save the changes.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Verify Open Graph Tags Installation<\/h2>\n\n\n\n<p>Now it&#8217;s time to ensure that your Open Graph tags have been successfully implemented.<\/p>\n\n\n\n<p>There are 2 ways to do it, Use our own <a href=\"https:\/\/kwebby.com\/open-graph-checker\" data-type=\"link\" data-id=\"https:\/\/kwebby.com\/open-graph-checker\" target=\"_blank\" rel=\"noreferrer noopener\">Open graph checker tool<\/a>, all you need to do is to type your blog URL in the box below;<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"450\" src=\"https:\/\/kwebby.com\/blog\/wp-content\/uploads\/2023\/12\/open-graph-checker-tool-1024x450.png\" alt=\"\" class=\"wp-image-17405\" title=\"\" srcset=\"https:\/\/kwebby.com\/blog\/wp-content\/uploads\/2023\/12\/open-graph-checker-tool-1024x450.png 1024w, https:\/\/kwebby.com\/blog\/wp-content\/uploads\/2023\/12\/open-graph-checker-tool-300x132.png 300w, https:\/\/kwebby.com\/blog\/wp-content\/uploads\/2023\/12\/open-graph-checker-tool-768x338.png 768w, https:\/\/kwebby.com\/blog\/wp-content\/uploads\/2023\/12\/open-graph-checker-tool-1536x676.png 1536w, https:\/\/kwebby.com\/blog\/wp-content\/uploads\/2023\/12\/open-graph-checker-tool.png 2026w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Click on Submit and you will see the following details (if your installation is successful);<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"413\" src=\"https:\/\/kwebby.com\/blog\/wp-content\/uploads\/2023\/12\/Open-Graph-Checker-_-Kwebby-and-12-more-pages-Personal-Microsoft\u200b-Edge-1024x413.png\" alt=\"\" class=\"wp-image-17406\" title=\"\" srcset=\"https:\/\/kwebby.com\/blog\/wp-content\/uploads\/2023\/12\/Open-Graph-Checker-_-Kwebby-and-12-more-pages-Personal-Microsoft\u200b-Edge-1024x413.png 1024w, https:\/\/kwebby.com\/blog\/wp-content\/uploads\/2023\/12\/Open-Graph-Checker-_-Kwebby-and-12-more-pages-Personal-Microsoft\u200b-Edge-300x121.png 300w, https:\/\/kwebby.com\/blog\/wp-content\/uploads\/2023\/12\/Open-Graph-Checker-_-Kwebby-and-12-more-pages-Personal-Microsoft\u200b-Edge-768x310.png 768w, https:\/\/kwebby.com\/blog\/wp-content\/uploads\/2023\/12\/Open-Graph-Checker-_-Kwebby-and-12-more-pages-Personal-Microsoft\u200b-Edge-1536x620.png 1536w, https:\/\/kwebby.com\/blog\/wp-content\/uploads\/2023\/12\/Open-Graph-Checker-_-Kwebby-and-12-more-pages-Personal-Microsoft\u200b-Edge-2048x826.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>If you see a preview with all relevant details, including title, description, image, and other essential elements, congratulations! You&#8217;ve successfully added OG tags without using a WordPress Plugin.<\/p>\n\n\n\n<p>Alternatively, You can use Facebook&#8217;s Sharing debugger to<\/p>\n\n\n\n<p>Go to <a href=\"https:\/\/developers.facebook.com\/tools\/debug\/sharing\/batch\/\" target=\"_blank\">Facebook&#8217;s Sharing Debugger<\/a> and enter the URL of any post or page from your WordPress site and you will see no issues if your integration is successful as below;<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"347\" src=\"https:\/\/kwebby.com\/blog\/wp-content\/uploads\/2023\/12\/facebook-sharing-debugger-1024x347.png\" alt=\"\" class=\"wp-image-17407\" title=\"\" srcset=\"https:\/\/kwebby.com\/blog\/wp-content\/uploads\/2023\/12\/facebook-sharing-debugger-1024x347.png 1024w, https:\/\/kwebby.com\/blog\/wp-content\/uploads\/2023\/12\/facebook-sharing-debugger-300x102.png 300w, https:\/\/kwebby.com\/blog\/wp-content\/uploads\/2023\/12\/facebook-sharing-debugger-768x260.png 768w, https:\/\/kwebby.com\/blog\/wp-content\/uploads\/2023\/12\/facebook-sharing-debugger-1536x521.png 1536w, https:\/\/kwebby.com\/blog\/wp-content\/uploads\/2023\/12\/facebook-sharing-debugger-2048x694.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Also Checkout, <a href=\"https:\/\/kwebby.com\/blog\/add-twitter-card-meta-data-wordpress\/\">How to Add Twitter Card Meta Data in WordPress (Without Plugin)<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">More Meta Tags Resources<\/h2>\n\n\n\n<p><a href=\"https:\/\/kwebby.com\/blog\/optimize-meta-title-and-meta-description\/\">How to Optimize Meta Title and Meta Description for SEO in WordPress in 2023<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/kwebby.com\/blog\/most-important-meta-tags-seo\/\">9 Most Important Meta Tags You Need to Know for SEO<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Meta Tags Tools<\/h2>\n\n\n\n<p><a href=\"https:\/\/kwebby.com\/open-graph-checker\/\" target=\"_blank\" data-type=\"link\" data-id=\"https:\/\/kwebby.com\/open-graph-checker\/\" rel=\"noreferrer noopener\">Open Graph Checker<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/kwebby.com\/open-graph-generator\" data-type=\"link\" data-id=\"https:\/\/kwebby.com\/open-graph-generator\">Open Graph Generator<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/kwebby.com\/meta-tag-generator\" data-type=\"link\" data-id=\"https:\/\/kwebby.com\/meta-tag-generator\">Meta Tag Generator<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/kwebby.com\/meta-tags-analyzer\" data-type=\"link\" data-id=\"https:\/\/kwebby.com\/meta-tags-analyzer\">Meta Tag Analyzer<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>In this guide, we have successfully demonstrated how you can add OG tags in WordPress without the reliance on a plugin. We hope that through following our step-by-step process, you have been able to implement these tags seamlessly into your site.<\/p>\n\n\n\n<p>By doing so, you not only enhance the visibility and click-through rates of your content but also maintain a professional and efficient website. So, why wait? Start optimizing your WordPress site for social media shares today and watch your online presence grow!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Optimizing your WordPress site for social media shares is crucial in today&#8217;s digital landscape, and one of the keys to this optimization is the proper&hellip;<\/p>\n","protected":false},"author":1,"featured_media":17410,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[408,404],"tags":[],"class_list":["post-17399","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-social-media-tutorials","category-wordpress-tutorials"],"_links":{"self":[{"href":"https:\/\/kwebby.com\/blog\/wp-json\/wp\/v2\/posts\/17399","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kwebby.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kwebby.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kwebby.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kwebby.com\/blog\/wp-json\/wp\/v2\/comments?post=17399"}],"version-history":[{"count":7,"href":"https:\/\/kwebby.com\/blog\/wp-json\/wp\/v2\/posts\/17399\/revisions"}],"predecessor-version":[{"id":17620,"href":"https:\/\/kwebby.com\/blog\/wp-json\/wp\/v2\/posts\/17399\/revisions\/17620"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kwebby.com\/blog\/wp-json\/wp\/v2\/media\/17410"}],"wp:attachment":[{"href":"https:\/\/kwebby.com\/blog\/wp-json\/wp\/v2\/media?parent=17399"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kwebby.com\/blog\/wp-json\/wp\/v2\/categories?post=17399"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kwebby.com\/blog\/wp-json\/wp\/v2\/tags?post=17399"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}