‘posts_per_page’ is saved as an option;
try (untested; will depend on the location where you add the lines into the plugin’s code):
$temppp = get_option( 'posts_per_page' );
update_option( 'posts_per_page', 10 );
/*SLIDER*/
update_option( 'posts_per_page', $temppp );
http://codex.wordpress.org/Function_Reference/get_option
http://codex.wordpress.org/Function_Reference/update_option
Thanks for the suggestion! It seems no matter where I put it, it generates an error at the next function. Here’s an example bit of code:
/* Set max-posts-per-page option */
$temppp = get_option( 'posts_per_page' );
update_option( 'posts_per_page', 10 );
/**
* Do things on plugin activation.
*
* @since 0.1
*/
function responsive_slider_activation() {
The last line is 102, and this is the error:
Parse error: syntax error, unexpected T_FUNCTION, expecting T_STRING or T_VARIABLE or ‘$’ in /home/jmountai/public_html/the/wp-content/plugins/responsive-slider/responsive-slider.php on line 102
I just stuck the code inside and at the end of a previous function: function responsive_slider_setup()
I got a different kind of error then:
Parse error: syntax error, unexpected ‘}’, expecting T_STRING or T_VARIABLE or ‘$’ in /home/jmountai/public_html/the/wp-content/plugins/responsive-slider/responsive-slider.php on line 96
Line 96 is the closing } for that function.
I tried putting the code inside the function that does the main job:
function responsive_slider($id = 0) {
/* Set max-posts-per-page option */
$temppp = get_option( 'posts_per_page' );
update_option( 'posts_per_page', 10 );
$slides = new WP_Query( array( 'post_type' => 'slides', 'order' => 'ASC', 'orderby' => 'menu_order', 'meta_key' => '_slider_id', 'meta_value' => $id ) );
The error generated was:
Parse error: syntax error, unexpected ‘=’, expecting ‘)’ in /home/jmountai/public_html/the/wp-content/plugins/responsive-slider/responsive-slider.php on line 244
Line 244 is the last line in the code above.
this is the main function, where the number of post could be set directly into the query args:
in responsive-slider.php (line 237, about one-third down)
function responsive_slider() {
$slides = new WP_Query( array( 'post_type' => 'slides', 'order' => 'ASC', 'orderby' => 'menu_order' ) );
the easiest way is probably to forget to minipulate the ‘posts_per_page’ options, but to add the number of posts directly into the code:
function responsive_slider() {
$slides = new WP_Query( array( 'post_type' => 'slides', 'order' => 'ASC', 'orderby' => 'menu_order', 'posts_per_page' => 10 ) );
Am I ever embarrassed! I copied the code directly from this web page and pasted it into the PHP file. The single quote was converted to the &# code, and that was what was generating the errors.
Your original code works just fine. I went ahead and tried your simplied solution, and it works as well.
Thank you so much for this help. I was beginning to despair of finding a responsive slider that would work.