🙏 How to change the image randomly and automatically that appears when you post a link on Facebook?

sergiosouza

Active member
Aug 12, 2019
207
40
28
Hello everyone, everything good? I would like some help. Does anyone know any code or wordpress plugin that has the functionality to change the shared image of my website, that is, every time someone publishes the link to my website on facebook, the image that is generated must be different and not a single image.
 

sergiosouza

Active member
Aug 12, 2019
207
40
28
Hi, Sergio.
i Think yoast could help you.

Take a look on their doc ;D


Gl, kinsman!

Hello @justcamehere , first thanks for your reply. I read what is on the link you sent, but I believe it would not be what I am looking for. What I want is a script or plugin, which randomly and automatically modifies the image that appears when the link is posted on Facebook, that is, when a person posts my link on Facebook, an image will appear (preferably that can be chosen beforehand inside a folder) and some time later when another person will post the same link on Facebook, another image will appear (which will be inside this same folder, for example). This would serve to do a type of AB test, to see which image engages the most in the publication.
 

sergiosouza

Active member
Aug 12, 2019
207
40
28
Good morning, Sergio!
Did you already try this one?
Unfortunately this plugin does not change the image when you post the link on Facebook, it is always the first. I have a code, at the beginning of last year it worked, but I tried this week and it is giving an error. I don't know if I'm doing something wrong.
 

sergiosouza

Active member
Aug 12, 2019
207
40
28
Put the code here, i'll try to take a look 🧐🧐🧐🧐🧐
I am testing to post, but this message appears:

Oops! We ran into some problems.
Oops! We ran into some problems. Please try again later. More error details may be in the browser console.
 

sergiosouza

Active member
Aug 12, 2019
207
40
28
justcamehere

Would it be this:

Place this code in the header.php just below <? php
function random_pic($dir, $nf=3)

{

$files = glob($dir . DIRECTORY_SEPARATOR . '*.jpg');

shuffle($files);

return array_pop($files);

}

//$number = rand(); ?v=$number

$path = 'images';

$file_1 = random_pic($path, 1);

$image = file_get_contents($file_1);

$og_img = base64_encode($image);


and then put this code before </head>

<meta name="twitter:card" value="summary">

<meta property="fb:app_id" content="224711598334964" />

<meta property="og:title" content="This is what you need !" />

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

<meta property="og:url" content="http://yoursite.com" />

<meta property="og:image" content="http://yoursite.com/<?php echo $file_1 ?>" />

<meta property="og:description" content="Liked it? Click Here & Get it for FREE."/>

<meta property="og:site_name" content="yoursite.com - What Do You Need?"/>

And also create a folder in your hosting called "Images" and place the images that you want to appear. I believe it would be something:
 
Last edited:

Online Hustle

New member
Mar 19, 2021
26
9
3
justcamehere

Would it be this:

Place this code in the header.php just below <? php
function random_pic($dir, $nf=3)

{

$files = glob($dir . DIRECTORY_SEPARATOR . '*.jpg');

shuffle($files);

return array_pop($files);

}

//$number = rand(); ?v=$number

$path = 'images';

$file_1 = random_pic($path, 1);

$image = file_get_contents($file_1);

$og_img = base64_encode($image);


and then put this code before </head>

<meta name="twitter:card" value="summary">

<meta property="fb:app_id" content="224711598334964" />

<meta property="og:title" content="This is what you need !" />

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

<meta property="og:url" content="http://yoursite.com" />

<meta property="og:image" content="http://yoursite.com/<?php echo $file_1 ?>" />

<meta property="og:description" content="Liked it? Click Here & Get it for FREE."/>

<meta property="og:site_name" content="yoursite.com - What Do You Need?"/>

And also create a folder in your hosting called "Images" and place the images that you want to appear. I believe it would be something:
it seem you are using the ultimate google Adsense method? I am right? Can you tell me if the method still works or not?
I have seen the course. but haven't tried it yet?
 

sergiosouza

Active member
Aug 12, 2019
207
40
28
it seem you are using the ultimate google Adsense method? I am right? Can you tell me if the method still works or not?
I have seen the course. but haven't tried it yet?
I wasn't really trying to do the method. I just wanted the featured image to change every time someone shared my link, to do an AB test
 

About us

  • Our community has been around for many years and pride ourselves on offering unbiased, critical discussion among people of all different backgrounds. We are working every day to make sure our community is one of the best.

Quick Navigation

User Menu