Jump to content
TNG Community
John Paul

Randomphoto question(s)

Recommended Posts

John Paul

Good Morning all.

On my localhost testing site, I'm using wp-tng Kloosterman setup, wp v6.02, astra pro as my theme and elementor pro as my page editor.

Does anyone use the tng randomphoto.php on their homepage?  I was looking in the WordPress forum here and only saw 2 posts about it, but those were from 2014 and really didn't help much.  I know there are a bunch of wordpress plugins for random images, but I would like to know how to use tng's randomphoto.php.  Any help or suggestions will be greatly appreciated

I'm in the process of setting up a sub domain to setup what I have on my test site and will post the site here when I think it's ready for folks to have a look.

Share this post


Link to post
Share on other sites
mahesh

Not sure if this helps: I am using a slightly modified randomphoto.php in my home page. The page built using wordpress template.

Just wondering whether a wordpress shortcode could be bulit for this.

Share this post


Link to post
Share on other sites
John Paul
31 minutes ago, mahesh said:

Not sure if this helps: I am using a slightly modified randomphoto.php in my home page. The page built using wordpress template.

Just wondering whether a wordpress shortcode could be bulit for this.

Thanks Mahesh.  May I ask how you are calling randomphoto.php from wordpress?  are you using an include or require statement?  I've been trying different things for several days, including trying to create a working shortcode in wp, but with my somewhat limited knowledge, no luck.

btw, your site is pretty cool.

Share this post


Link to post
Share on other sites
John Paul

Mahesh, here's how the say to create a shortcode, but I don't understand how you would make the call to randomphoto.php...

image.png

and here's the link to that:

https://wpcodeus.com/how-to-add-php-code-to-elementor/

I'm sure this works with the WordPress page builder or however you made your pages....

Share this post


Link to post
Share on other sites
mahesh

Hi John Paul,

I do not know anything about elementor. I use a php file as a Wordpress template. My code for random photo is

$tng_randomphoto = __DIR__ . "/welcome/randomphoto_C.php";
			<!-- Random Photo -------------------------->
			<div class="random-photo" style="margin-top: 30px;">
				<div><?php include($tng_randomphoto); ?>
				</div>
			</div>	

randomphoto_c.php  is a modified file located in the child theme. It fetches photos from acustomised folder which has deceased individuals only.

I am not sure why your shortcode is not working. Perhaps a user of Elementor can help.

What sort of error messages are you getting?

Share this post


Link to post
Share on other sites
John Paul

Thanks Mahesh.  I'm not getting any error messages.  But with your example I may be able to create a working shortcode.  I'll let you know how it goes.  Might be a little while though, I'm going for breakfast now!

Share this post


Link to post
Share on other sites
John Paul

Mahesh, I just can't get my head wrapped around this shortcode thing...yet.  And I' not understanding how you get your code into WordPress to show the randomphotos.php file.  is that code a separate php file?  Do you use a widget or something?  I'm usually somewhat ok at this stuff, but I'm on pain meds for my back these days and just not thinking straight.  So treat me like a total newbie.

Share this post


Link to post
Share on other sites
mahesh
37 minutes ago, John Paul said:

Mahesh, I just can't get my head wrapped around this shortcode thing...yet.  And I' not understanding how you get your code into WordPress to show the randomphotos.php file.  is that code a separate php file?  Do you use a widget or something?  I'm usually somewhat ok at this stuff, but I'm on pain meds for my back these days and just not thinking straight.  So treat me like a total newbie.

I think we are talking about 2 diffrent things. I had my TNG Shortcode Constructor plugin in mind. I see, now, that you are using a shortcode inserter in Elementor. I have absolutely no idea how that works.

Let me think about it for a while.

Bear in mind that the PHP you insert  needs to be able to access  the TNG database to get to media table.

I am sure you will sort it out

Share this post


Link to post
Share on other sites
John Paul

Let me re-phrase my original question.  How would I go about creating a WordPress shortcode to return the content of a tng php file?  Specifically the randomphoto.php file?

Share this post


Link to post
Share on other sites
John Paul

ok, I'm trying now to do this via the html way.  I'ts been the furthest I've gotten, but can't get the pics to display.  If any one has any comments or suggestions, I'd be glad to hear them.

the html code: (localhost is needed as it's WAMPServer...and I have other test sites under www)
 

<div>
    <a href="http://localhost/wordpress/wp-tng/randomphoto.php">
        <img border="0" width="270" height="270">
    </a>
</div>

and here's a screenshot:
image.png

The code, css and title are just temporary, but I hope you get the idea...

Share this post


Link to post
Share on other sites
mahesh

Looks like you may have to Try real path instead of URL in include statement.

Share this post


Link to post
Share on other sites
John Paul


 

14 minutes ago, mahesh said:

Looks like you may have to Try real path instead of URL in include statement.

Thanks Mahesh, but using Elementor page editor (I know you don't use elementor) only allows html and not php.  Fo that I have to make the shortcode, which I haven't been able to figure out yet.  Made me think of spmething to try...

Is there a way to use the include statement in html? the

<div><?php include('/wp-tng/randomphoto.php'); ?></div>

will not work as it is a php statement (in elementor) so I need a shortcode.  but I thought of something to try....I'll let you know...

Share this post


Link to post
Share on other sites
mahesh
47 minutes ago, John Paul said:

<div><?php include('/wp-tng/randomphoto.php'); ?></div>

will not work as it is a php statement (in elementor) so I need a shortcode.  but I thought of something to try....I'll let you know...

I might be completely wrong but this will not work.😞.

randomphoto.php requires access to showmedia.php, media_table and access to the database. This may not be possible outside the scope of tng folder.

I am in the middle of something at the moment but this seems like an intesting project.  interesting. I may try to work out shortcode to work in my TNG Shortcode Constructor FOR Wordpress.

Please do let us know how you get on.

Share this post


Link to post
Share on other sites
John Paul

Thanks Mahesh.  FYI, although tng is in a sub folder of WordPress, they both use the same database...hope that helps you some..my file structure looks like this:

wamp64
www
----wordpress
------wp-admin
------wp-content
------wp-includes
------wp-tng
--------tng files and folders

Share this post


Link to post
Share on other sites
bhemph

The only way an HTML file knows PHP is like

<iframe src="/wp-tng/randomphoto.php" width="270" height="270"></iframe>

If this creates an iframe inside an iframe, it may start eating more memory on the user's device.

Share this post


Link to post
Share on other sites
John Paul
2 hours ago, bhemph said:

The only way an HTML file knows PHP is like


<iframe src="/wp-tng/randomphoto.php" width="270" height="270"></iframe>

If this creates an iframe inside an iframe, it may start eating more memory on the user's device.

thanks bhemph, I read about that somewhere....I'll give it a shot and see what happens.

EDIT:  Well that didn'y work either:
image.png

Share this post


Link to post
Share on other sites
mahesh
On 9/26/2022 at 4:18 PM, John Paul said:

thanks bhemph, I read about that somewhere....I'll give it a shot and see what happens.

EDIT:  Well that didn'y work either:
image.png

I have got it working in my Shortcode Constructor plugin. Will Post link to the Version 1.03, tomorrow.😉

Share this post


Link to post
Share on other sites
John Paul
2 hours ago, mahesh said:

I have got it working in my Shortcode Constructor plugin. Will Post link to the Version 1.03, tomorrow.😉

Thanks Mahesh, will be looking forward to it.

Share this post


Link to post
Share on other sites
mahesh
20 hours ago, John Paul said:

Thanks Mahesh, will be looking forward to it.

I was unable to get the randomphoto.php to work outside the tng folder.

So, I have added a modified version of random photo shortcode (which I use on my home page) to TNG SHORTCODE CONSTRUCTOR FOR WORDPRESS.

Current version, still under test & development, is here.

Random Photo (under development):
This is a modified version of randomphoto.php. This is for you, @John Paul. You may change it to suit your requirements. If you do decide to use it, please share your changes so that I can update the shortcode.

Shortcode: TngWp_RandomPhoto

CSS: 
 .random-frame sets the frame
 .random-photo sets the image
 width is fixed at 220px which you may change

 SQL Condition:
default photo = 1 and living = 0
  or
 always on = 1

TNG Search Widget (under test):
Shortcode:
TngWp_search
This legacy Widget searches names in TNG database. The widget requires a Wordpress page to display search results.
 Widget will only be activate if a Wordpress page for the widget is created.

Good Luck. Look forward to your success story.

Edited by mahesh
loads of white space!!

Share this post


Link to post
Share on other sites
John Paul

Thanks Mahesh.  I'll have took at it a little later.  kind of busy this afternoon.

One question though is about the SQL condition.  do I add that to the shortcode?

I'll let you know how it goes and thanks again.

Share this post


Link to post
Share on other sites
mahesh
3 hours ago, John Paul said:

One question though is about the SQL condition.  do I add that to the shortcode?

Should work straight from the box. You will have to specify things like TNG path, in settings.

SQL condition is already set to show default photos of deceased (living = 0 ) or default photos marked as Always On.

Share this post


Link to post
Share on other sites
John Paul

One more 'dumb' question....do I install this as a WordPress plugin?

Never mind, It installed fine in wordpress....duh...too early in the am right now...

Share this post


Link to post
Share on other sites
John Paul

Trying to set it uo but got this :

WP TNG Shortcodes Option.png

Share this post


Link to post
Share on other sites
John Paul

looks like it also changed all the custom css I had in the astra theme and in elementor....

I uninstalled the plugin and all the css came back...what's up with that?

Edited by John Paul
Update

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×