Title: replace integers with variables
Last modified: August 19, 2016

---

# replace integers with variables

 *  Resolved [abigcity](https://wordpress.org/support/users/abigcity/)
 * (@abigcity)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/replace-integers-with-variables/)
 * hacking around some wordpress default theme.
 * what i am trying to do is create a custom page template that when applied shows
   posts in that category using post meta. this is working well.
 * however, i’d also like the menu to display only the parent category and children
   of that the category.
 * i’m trying to replace `child_of=3` to `child_of=$categori_id`
 * here is the code
 *     ```
       <div id="sidebar" class="internet_bar">
       			<ul>	<?php
       				if (is_page() ) {
       			$categorize = get_post_meta($posts[0]->ID, 'category', true);
       			}
       		if ($categorize) {
       			$categori = get_the_category();
       			$categori_id = get_cat_ID($categorize);
   
       				echo "<li>" . $categorize ."</li>";
       				$categlories=  get_categories('child_of=3');
       		  foreach ($categlories as $categlory) {
       		  	$option = '<li>'.$categlory->category_nicename.'</li>';
   
       			echo $option;
       		  }
   
       		}
       		?> 
   
       			</ul>
       			</div>
       ```
   
 * example page of this code here – [http://bedepressed.org/criticalgeography/online](http://bedepressed.org/criticalgeography/online)
 * online only is parent, other two categories are children

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

 *  [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * (@vtxyzzy)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/replace-integers-with-variables/#post-1718212)
 * Not quite sure, but I think this is what you want:
 * `$categlories= get_categories("child_of=$categori_id");`
 *  Thread Starter [abigcity](https://wordpress.org/support/users/abigcity/)
 * (@abigcity)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/replace-integers-with-variables/#post-1718223)
 * fucking beautiful, thank you. when i tried i put my quotes in several of the 
   wrong places. thanks again.

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

The topic ‘replace integers with variables’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [abigcity](https://wordpress.org/support/users/abigcity/)
 * Last activity: [15 years, 8 months ago](https://wordpress.org/support/topic/replace-integers-with-variables/#post-1718223)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
