Title: Using PHP echo to get category number problem
Last modified: August 19, 2016

---

# Using PHP echo to get category number problem

 *  [knight42](https://wordpress.org/support/users/knight42/)
 * (@knight42)
 * [17 years, 7 months ago](https://wordpress.org/support/topic/using-php-echo-to-get-category-number-problem/)
 * Hi all
 * I have a random PHP question if anyone can help. Have done a search, but cannot
   find the right awnser (Maybe Im not looking in the right places mind!!)
 * I have 3 loops in different sections of a page, each calling posts from the same
   category. Im actually giving this template to someone else, so Im trying to make
   it simple, so I thought rather than have them put the cat number in on three 
   separate lines I would just have one at the top and use a PHP echo to reference
   it….but I cant do it!!!
 * So at the top of the page I have an echo like this
 * <?php>
 * $foo = “1”;
    $bar = “2”;
 * ?>
 * It works as an echo on the page just fine, have tried it. But I cant figure the
   correct PHP to call it (im new to PHP so this maybe easy I dunno!) I have this
   at the moment
 * `<?php $top_query = new WP_Query('showposts=10&cat=<?php echo "$bar"; ?>&offset
   =1'); ?>`
 * But it doesnt work.
 * If anyone could help I would be most happy. Thanks people!

The topic ‘Using PHP echo to get category number problem’ is closed to new replies.

## Tags

 * [php](https://wordpress.org/support/topic-tag/php/)

 * 0 replies
 * 1 participant
 * Last reply from: [knight42](https://wordpress.org/support/users/knight42/)
 * Last activity: [17 years, 7 months ago](https://wordpress.org/support/topic/using-php-echo-to-get-category-number-problem/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
