Title: simple php question
Last modified: August 19, 2016

---

# simple php question

 *  [zedesino](https://wordpress.org/support/users/zedesino/)
 * (@zedesino)
 * [17 years, 11 months ago](https://wordpress.org/support/topic/simple-php-question-1/)
 * hello, i hope this is simple question for php programers.
 * i have wordpress code:
 * `<?php glmdobcatranpost('21','0','2'); ?>`
 * and on the place where is 0 (zero) i want to add this
 *     ```
       <?php
       foreach((get_the_category()) as $category) {
           echo $category->term_id . ' ';
       }
       ?>
       ```
   
 * thank you coders.

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Thread Starter [zedesino](https://wordpress.org/support/users/zedesino/)
 * (@zedesino)
 * [17 years, 11 months ago](https://wordpress.org/support/topic/simple-php-question-1/#post-801043)
 * edit:
    so i’m using plugin category magic. plugin works like that you add three
   digits (‘x’,’y’,’z’) x is first category y is second and z is number of post 
   i want to show.
 * So i have one constant category ‘x’ and 50 different so for each of those 50 
   categories i have one post that are also in ‘x’ category. And i want when i’m
   on website.com/category/category-y to be able to read automaticly id of category‘
   y’ and to add to plugin query and plugin will show me link to post that is related
   to category ‘x’ and also to current category ‘y’
 *  [Roger Theriault](https://wordpress.org/support/users/rogertheriault/)
 * (@rogertheriault)
 * [17 years, 11 months ago](https://wordpress.org/support/topic/simple-php-question-1/#post-801059)
 * Simply rearrange like this
 *     ```
       <?php
       $categorylist = "";
       foreach((get_the_category()) as $category) {
           $categorylist .= $category->term_id . ' ';
       }
       glmdobcatranpost('21',$categorylist,'2'); ?>
       ```
   
 *  Thread Starter [zedesino](https://wordpress.org/support/users/zedesino/)
 * (@zedesino)
 * [17 years, 11 months ago](https://wordpress.org/support/topic/simple-php-question-1/#post-801062)
 * wow!
    thank you this works great. I know was possible but my knowledge of php
   is bad.
 * Interesting, now works perfect, if doesn match two categories i dont get any 
   result. it’s excellent.
 *  [Roger Theriault](https://wordpress.org/support/users/rogertheriault/)
 * (@rogertheriault)
 * [17 years, 11 months ago](https://wordpress.org/support/topic/simple-php-question-1/#post-801075)
 * You’re welcome. Your problem description was pretty good. I don’t think I’d do
   nearly as well asking a technical question in a language other than my native
   English. I’d probably even mess it up in French. And someone would have to tell
   me to go look in the manual 🙂

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘simple php question’ is closed to new replies.

 * 4 replies
 * 2 participants
 * Last reply from: [Roger Theriault](https://wordpress.org/support/users/rogertheriault/)
 * Last activity: [17 years, 11 months ago](https://wordpress.org/support/topic/simple-php-question-1/#post-801075)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
