Jump to content

Wordpress PHP help


Tonyzomba

Recommended Posts

Hey guys. I am Looking for some help here, dunno where else to ask, but im sure someone will know where my problem is.

 

I got this wordpress theme and cant work out whats wrong with the display image. on front end i can set the image as main image heres the php of it

<?php
ini_set( 'display_errors', 0 );
require( '../../../../wp-load.php' );
if (!is_user_logged_in()) { die(); }

$attachmentid = (int)$_GET['id'];
if ($attachmentid == 0) { die(); }

global $current_user;
get_currentuserinfo();
$userid = $current_user->ID;

$post = get_post($attachmentid);
$photo = $post->post_title;
$post_parent = get_post($post->post_parent);
$upload_folder = get_post_meta($post_parent->ID, "upload_folder", true);
$author_id = $post_parent->post_author;

//if the current user is the one who added the post
if ($author_id == $userid || current_user_can('level_10')) {
	update_post_meta($post->post_parent, "main_image_id", $upload_folder."/".$photo);
	echo _d('Default image has been set',779)."<br />"._d('Refresh the page to see it change',780);
}
?>

and im not quite sure whats happening here, im a total ROOKIE at php as a matter of fact :( 

so yeah...

the second part... the loop where its supposed call for the image, i cant really find it in all those files...

 

maybe if somebody explains to me what happens in the last 4 liines i might figure out whats wrong?

Link to comment
Share on other sites

If you are new to WordPress, then you've probably dug a little too deep.  WordPress can be quite confusing for someone who is new to it, and often changes and alterations are to be made from the Admin page, and not within the code of the theme itself.  When you play with php within WordPress, unless you're experienced and/or careful, you're probably going to make a colossal blunder (in my experience).

 

However, if you truly must play with the code then here is my take:

 

This piece of code does have something to do with an image.  However, this seems to set a bunch of variables, but does not actually produce any HTML which displays an image.  It seems to me like either your question is too vague/confusing to me, or you're looking in the wrong place.

 

As far as I can tell the last four lines of code basically check whether you have the rights and privileges required to set the main image.

 

Sorry that I can't be of more help.

Link to comment
Share on other sites

Hey thanks for the reply, im not new to wordpress bad im very poor php knowledge, i cant write it but i can read and get the aproximate meaning of it. so yeah my question is maybe the code is reuploading the image to another folder and i need to have a folder or for that matter or what exactly it is doing? this piece of code is not displaying the image its for setting the main image, just what the process is, how does it set it to main image? 

i will try to find the code that actually has to display it. Just this theme is a little too big lol, its got 40 pages of php, and cant find the loop of the profiles or single post :/ maybe if someone could take a look from an Admin to it, i'd give access to the site. Waiting for my savior))

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.