Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a WordPress Admin page where you can add a "listing" within this Admin Page I have added many fields which transfer variables over to the listing page which is created/updated. Within this admin page I am trying to take the string after the last "&" in the url which is manually enter in the url before loading the page see code below:

 $url = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
 $id = substr( $url, strrpos( $url, '&' )+1 );

NOW the code below here is called when the ABOVE admin page is submitted to update the "listing" what I need to do is somehow get the variable $id to pass through to this function and be used again within the submit code. Both of these functions are within functions.php so somehow it should be easy to do this!

This may not be "Wordpress Specific" but is a Wordpress Specific situation where I had this code working on a non-wordpress site. Please help!

    $dirname = "../wp-content/themes/Explorable/".$id."/"; 
  $images = glob($dirname."*.jpg");
// Open a known directory, and proceed to read its contents  
foreach($images as $image) {
 $imageNameLong = substr($image, -14);
$imageName = substr($imageNameLong,0 , -4);

 if ( isset( $_POST[$imageName.'links'] ) )
            update_post_meta( $post_id, '_'.$imageName.'links', sanitize_text_field( $_POST[$imageName.'links'] ) );
        else
            delete_post_meta( $post_id, '_'.$imageName.'links' ); 

    if ( isset( $_POST[$imageName.'heading'] ) )
            update_post_meta( $post_id, '_'.$imageName.'heading', sanitize_text_field( $_POST[$imageName.'heading'] ) );
        else
            delete_post_meta( $post_id, '_'.$imageName.'heading' ); 
};
share|improve this question

migrated from webapps.stackexchange.com Nov 11 '13 at 13:50

This question came from our site for power users of web applications.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.