Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Placing an array within a a loop WordPress


ok, I think this is a simple one, but I was up til 4.30 this morning trying to figure it out and got nowhere. I'm sure that it is obvious for those in the know.

I have set up in my admin to type in the number of posts to show and the category id (as my fiance is no good with code and it is her site).

This is what I have right now:
<?php $my_query = new WP_Query('showposts=2&cat=13'); ?>

However, for the showposts, I have the following array to use instead of <em><strong>2</strong></em>:

<?php $section1_categoryid = get_option('section1_categoryid'); echo $section1_categoryid; ?>;

And for the cat ID, I have the following array instead of <em><strong>13</strong></em>:

<?php $section1_numberofposts = get_option('section1_numberofposts'); echo $section1_numberofposts; ?>;

The code works fine on its own, but how would I include it in the above $my_query code?


Answers (1)


Utkarsh Kukreti answers:

<?php $my_query = new WP_Query("showposts=$section1_numberofposts&cat=$section1_categoryid"); ?>

Joe Jenkins comments:

That got me onto the right track.

I had to also add the following earlier in the code:
<?php $section1_numberofposts = get_option('section1_numberofposts');?>
<?php $section1_categoryid = get_option('section1_categoryid');?>

However, it got me there, which is what I needed.

Thanks :O)