Welcome to Techno Smarter QA, Questions, Answers Community
+4 votes
130 views

I have created social links for the blog post in PHP but when I am sharing it's not showing that blog picture.

Every time when I am sharing a blog it's not sharing that blog description and blog image.

Its taking page image and Its meta description.  How can I change the description for every new blog post which I am sharing?

This is the code of blog post sharing. 



<div class="pro-bot-shar">

            <h4>Share this post</h4>

            <?php

            $fb_url = $webpage_full_link. "blog-details?src=facebook&&row=".$blog_codea;  //URL Blog Detail  Facebook Link

            $fb_link = urlencode($fb_url);

            $twitter_url = $webpage_full_link. "blog-details?src=twitter&&row=".$blog_codea;  //URL Blog Detail Twitter Link

            $twitter_link = urlencode($twitter_url);

            $linkedin_url = $webpage_full_link. "blog-details?src=linkedin&&row=".$blog_codea;  //URL Blog Detail Linkedin Link

            $linkedin_link = urlencode($linkedin_url);

            $whatsapp_url = $webpage_full_link. "blog-details?src=whatsapp&&row=".$blog_codea;  //URL Blog Detail Whatsapp Link

            $whatsapp_link = urlencode($whatsapp_url);

            ?>

            <ul>

                <li>

                    <div class="sh-pro-shar sh-pro-face">

                        <a target="_blank" href="http://www.faceboo

k.com/sharer/sharer.php?href=<?php echo $fb_link; ?>"><img src="images/social/3.png" alt=""> Facebook</a>

                    </div>

                </li>

                <li>

                    <div class="sh-pro-shar sh-pro-twi">

                        <a target="_blank" href="http://twitter.com/share?text=<?php echo $events_a_row['event_name']; ?>&url=<?php echo $twitter_link; ?>"><img src="images/social/2.png" alt=""> Twitter</a>

                    </div>

                </li>

                <li>

                    <div class="sh-pro-shar sh-pro-link">

                        <a target="_blank" href="https://www.linkedin.com/sharing/share-offsite/?url=<?php echo $linkedin_link; ?>"><img src="images/social/1.png" alt=""> Linkedin</a>

                    </div>

                </li>

                <li>

                    <div class="sh-pro-shar sh-pro-what">

                        <a target="_blank" href="whatsapp://send?text=<?php echo $whatsapp_link; ?>" data-action="share/whatsapp/share"><img src="images/social/6.png" alt=""> WhatsApp</a>

                    </div>

                </li>

            </ul>

        </div>

in PHP by (120 points) 1 7

6 Answers

+4 votes

This is a simple method to create social share buttons or icons in PHP with an MYSQL database. You can share only the link without description and blog post image. It depends on social share platforms like Facebook, Twitter, LinkedIn, Pinterest, etc. Facebook allows to share the links only and after the share link, you can write a short description on Facebook. Facebook fetches description automatically.  It's all depends on the social share networking site. Let's discuss twitter. You can share tags and page URLs with twitter sharing links. You can use the post title also. 

<a target="_blank" href="http://twitter.com/share?text=Visit the link &url=<?php echo $baseUrl.$slug; ?>&hashtags=blog,technosmarter,programming,tutorials,codes,examples,language,development">

Output- Try the link 

http://twitter.com/share?text= create-social-share-buttons-in-the-blog-using-php-and-mysql %7C PHP Tutorials &url=https://technosmarter.com/php/create-social-share-buttons-in-the-blog-using-php-and-mysql&hashtags=technosmarter,php,programming,tutorials

You can check other sharing links here - 

Create social share buttons in the blog using PHP and MYSQL

by (8.9k points) 8 22 61
Actually i already created social share link but when i  m clicking for facebook it automatically take website icon but not aking that blog picture.

Can you please tell how to give meta description for blogs individually
This is answered by vishalrana1. You should check.
+4 votes

We can share only links and text on social share sites if they allow. Social sites fetch images automatically if possible. The social site helps to share links, text or tags. You can check share URLs for that. 

If you want to set your meta description then follow the steps - 

Select short description form MySQL database 

Use meta description and echo the short description like this - 


<head> 

  <meta name="description" content="<?php $postshortdesc ; ?>">  

</head>

SEO part is more important for a blog. You can use HTML meta tags. In the example above, I used the meta description. 

by (6.7k points) 7 27 60
+3 votes

The blog system requires more than one table for operations. If you want to create a unique description for every single post then you have to create a column in your table. 

1. Create a column in your blog table - blogDesc

2. Insert post with description. Create a text area for a short description.

3. Use this column for SEO purposes. Select data from the database and echo with meta description. 

<head> 

  <meta name="description" content="<?php $blogDesc ; ?>">  

</head>

In this way, you can create a unique description for each blog post. 

by (4k points) 2 22 52
+3 votes

If you are sharing your blog posts and images are not showing then you should use social share plugins 

Facebook social share plugin 

https://developers.facebook.com/docs/plugins/share-button/

Twitter Social Plugin 

https://developer.twitter.com/en/docs/twitter-for-websites/tweet-button/overview

Linkedin 

https://developer.linkedin.com/plugins

Pinterest 

https://developers.pinterest.com/docs/widgets/save/

Use the links above and implement them. 

by (4k points) 2 22 52
+2 votes

Blog post images depend on the feature image and content images. Social sites fetch the image from your blog post page. You should use images with the blog posts. When you share blog posts on Facebook or another platform then social sites fetch images and descriptions from your blog post. Upload and attach unique images for different blog posts. 

You should create a unique description for each blog post. 

by (6.7k points) 7 27 60
I had created one blog in php and all new blog in stored in database so whenever i am sharing that blog its taking my website logo and description. How to give unique image and description for that particular blog?
I have answered your question. Add images for each blog post and get images on the Facebook share page. The image should be unique for each blog post and share unique links.
+1 vote

You are looking form social share links. If you want to share the blog post feature image on social sites then you should use meta properties. You will be able to share the post image on the PHP website. Along with feature image, you will be able to share website title, post description.  

 Share blog post image on social share sites like - Twitter, Facebook, Linkedin  

First of all, create social share buttons -  

Create social share buttons in the blog using PHP and MYSQL

Now, add meta in the <head> ......    </head> section. 

<meta property="og:url"           content="your-domain.com/your-page.html" />

  <meta property="og:type"          content="website" />

  <meta property="og:title"         content="Your Website Title" />

  <meta property="og:description"   content="Your description" />

  <meta property="og:image"         content="your-domain.com/path/image.jpg" />

 Provide the image path and other content from the MYSQ database. 

It will help to share your blog post feature image on social networking sites. 

by (430 points) 1 5
...