2195 posts
  • Has referred 200+ members
  • Has sold $500,000+ on Envato Market
  • Has collected 50+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+13 more
mpc says

Hi guys, as always while developing new theme I run into a problem. I have a slider and the slides for this slider are defined as custom posts. Each of the slides has custom additional settings (using custom meta box for this). As a slider engine I use the jQuery Slides.

For example one of the parameter for each slides is background color. When the slide changes I need to get the post id, I use the get_post_custom to read the custom meta data and then change with jQuery the background color, the only problem is that I cannot get the current post ID inside the PHP because all the posts are already on the page, hidden… I have an idea how to get the post ID inside the jQuery but again how to send it back to PHP ? ;/ Any help would be appreciated…

P.S Is really GET my only option? ;/ I hate this…

2195 posts
  • Has referred 200+ members
  • Has sold $500,000+ on Envato Market
  • Has collected 50+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+13 more
mpc says

I am seriously stuck :/ Any help would be great…

1875 posts YOU TOUCH IT YOU BUY IT
  • Has referred 200+ members
  • Has sold $500,000+ on Envato Market
  • Has collected 100+ items on Envato Market
  • Made it to the Authors' Hall of Fame
+6 more
FRESHFACE says

Hi!

here you can read how to handle ajax requests in WP: codex.wordpress.org/AJAX_in_Plugins

and for sending these requests, I personally use jQuery.post function.

hope I helped a lil bit :)

cheers, freshface

19 posts
  • Has referred 500+ members
  • Has sold $250,000+ on Envato Market
  • Has collected 1+ items on Envato Market
  • Located in United States
+4 more
DesignerThemes says

If you’re able to grab the ID with JavaScript, you can send it back to PHP with something like this:


//Get the ID from the HTML somewhere
var post_id = '10';

$.post('path/to/php/file.php', { 
     id: post_id
}, function(data)
     //Do something when completed
     console.log(data);
});

Then in your PHP file you would have this:

$id = $_POST['id'];

Hope that helps.

2195 posts
  • Has referred 200+ members
  • Has sold $500,000+ on Envato Market
  • Has collected 50+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+13 more
mpc says

Hi, guys I have done something else I have put all the data for my slides inside a PHP array and passed this array into JS I think this is the easiest solution ;)

by
by
by
by
by
by