• Resolved abigcity

    (@abigcity)


    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

    online only is parent, other two categories are children

Viewing 2 replies - 1 through 2 (of 2 total)
  • Not quite sure, but I think this is what you want:

    $categlories= get_categories("child_of=$categori_id");

    Thread Starter abigcity

    (@abigcity)

    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.