Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author tugbucket

    (@tugbucket)

    around line 137 in mctagmap_functions.php, you can change it to: https://pastebin.com/tweac7YV

    Not 100% tested but should probably work or at least get you close.

    Thread Starter cavanaughb

    (@cavanaughb)

    Thank you for the link! I’m testing the following code, but my page is still showing ALL pages of the site-map, instead of the child pages. Do you any have ideas?

    /* ===== set up what to get (tags, categories, etc...) ===== */
    	if($taxonomy){
    		$tags = get_terms($taxonomy, 'order=ASC&hide_empty='.$show_empty.'');
    	} elseif($show_categories == "yes"){
    		if($child_of != ""){
    			$childof = array();
    			$childof = preg_replace('/\s+/', '', explode(',',$child_of));
    			$tags = array();
    			foreach($childof as $kids){
    				$args = array(
    					'child_of' => $kids,
    					'order' => 'ASC'
    				);
    				$childcats = get_categories($args);
    				$tags = array_merge($tags, $childcats);
    			}
    		} else {
    			$tags = get_categories('order=ASC&hide_empty='.$show_empty.'');
    		}	
    
    	 	} elseif($show_pages == "yes"){
    		if($child_of != ""){
    			$childof = array();
    			$childof = preg_replace('/\s+/', '', explode(',',$child_of));
    			$tags = array();
    			foreach($childof as $kids){
    				$args = array(
    					'child_of' => $kids,
    					'order' => 'ASC'
    				);
    				$childcats = get_pages($args);
    				$tags = array_merge($tags, $childcats);
    			}
    		} else {
    			$tags = get_pages('sort_order=ASC&hide_empty='.$show_empty.'');
    		}
    	} elseif($from_category){
    		$tags = array();
    		$posts_array = get_posts('category='.$from_category.'&numberposts=-1');
    		foreach($posts_array as $pa) {
    			$tags = array_merge($tags, wp_get_post_tags($pa->ID));
    		}
    		$tmp = array();
    		foreach($tags as $k => $v){
        		$tmp[$k] = $v->term_id;
     		}
    		$tmp = array_unique($tmp);
     		foreach($tags as $k => $v){
        		if (!array_key_exists($k, $tmp)){
            		unset($tags[$k]);
    			}
    		}
    	} else {
    		$tags = get_terms('post_tag', 'order=ASC&hide_empty='.$show_empty.'');
    	}
    Thread Starter cavanaughb

    (@cavanaughb)

    Your code seems to be working perfectly–I just didn’t specify the conditional if statement correctly.

    This appears to be working. I will follow-up with more tests over the weekend. Once again, thank you for a great plug-in.

    } elseif($show_categories == "yes"){
    		if($child_of = "page_ID"){

    …where page_ID equals the identification number of the parent page.

    I changed accordingly and it works on the page that display only the child pages. But the other (site index) page that displays all categories and pages displays nothing now and stopped working. Please help.
    https://www.Sunnyvilleinc.com

    Plugin Author tugbucket

    (@tugbucket)

    Can you provide links to both pages?

    Plugin Author tugbucket

    (@tugbucket)

    on https://sunnyvilleinc.com/Total/site-index/

    you’re telling it to both show pages AND show categories. Limit that to the one you need and see what happens.

    show_categories => yes
        show_pages => yes

    It shows pages or categories if I select just one of them. So I can’t select both?

    Plugin Author tugbucket

    (@tugbucket)

    Pages uses get_pages
    categories uses get_categories

    so you’ll have to get both of those arrays, merge them and then sort and print the results.

    Possible? sure. out of the box? nope.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Only display child pages’ is closed to new replies.