×

Please Login or Register to continue.

4
(3.9K 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.

It's 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>

 

(120 Points)
in PHP

Share

6 Answers
(9.4K Points)
(edited)
4

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


Comment
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
vijay1996 15 Apr 2020
This is answered by vishalrana1. You should check.
shakti 15 Apr 2020

(7.3K Points)
(edited)
4

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. 


Comment

(4.3K Points)
(edited)
3

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. 


Comment

(4.3K Points)
(edited)
3

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. 


Comment

(7.3K Points)
(edited)
2

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. 


Comment
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?
vijay1996 24 Apr 2020
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.
vishalrana1 24 Apr 2020

(430 Points)
(edited)
1

You are looking for 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 images, you will be able to share website titles, post descriptions.  

 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. 


Comment

Related Questions :-

Featured Items:-


Certificate system in PHP website | PHP scripts

$22



Home Credito loan finance management multipurpose system in PHP

$65



Result management system with Marksheet in PHP website | PHP Scripts

$39




Your Answer

You can post your answer after login..