• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Get Tags for Array of Pages

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › Design Tips and Tricks › Get Tags for Array of Pages

This topic is: not resolved

Tagged: tags pages

  • This topic has 1 reply, 2 voices, and was last updated 10 years, 7 months ago by rfmeier.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • December 17, 2015 at 11:40 am #174090
    carrieoke13
    Participant

    Hi,
    I'm using a heavily modified Foodie Pro theme, and I've added the tag functionality to pages using this code:

    /** Enabling Categories and Tags Taxonomy for pages at Add/Edit Screen
     * 
     * @since 1.0
     * 
     */ 
    add_action('init', 'gd_register_category_tags_taxonomy_for_page');
    function gd_register_category_tags_taxonomy_for_page() {
    	register_taxonomy_for_object_type('post_tag', 'page');
    	register_taxonomy_for_object_type('category', 'page'); 
    }

    I have a page template that shows all grandchild pages of a certain page. Now, I want to show a list of all the tags that are associated with the pages that are shown on the template. The code I have now basically says, show me all grandchildren of this page:

    add_action( 'genesis_entry_content', 'rv_list_child_pages_with_thumbnails' );
    function rv_list_child_pages_with_thumbnails() {
    	
    	
    $all = get_pages();
    foreach($all as $all) { 
     if($all->post_parent) { 
      if( get_page($all->post_parent)->post_parent ) { 
       $tp = get_page($all->post_parent);
       if( !get_page( $tp->post_parent )->post_parent) { $grandchild_ids[] = $all->ID; }
      }
     }
    }
    
    $args = array(
    'post_type' => 'page',
    'post_status' => 'publish',
    'posts_per_page' => -1,
    'orderby' => 'ASC',
    'post__in' => $grandchild_ids
    );
    

    and I just want a list of their associated tags (as links). I am totally stumped. I tried this:

    $child_query = new WP_Query( $args );
    
    	if ( $child_query->have_posts() ) :
    
    	
    	//see if any posts have tags, if so; print a list 	
    		
    		while ( $child_query->have_posts() ) : $child_query->the_post();
    		$tags = get_tags();
    		
    	/foreach ($tags as $tag ) 
    	
    	{ $tag_link ($tag -> term_id);
    			
    			
    			$html .= "<a href='{$tag_link}' title='{$tag->name} Tag' class='{$tag->slug}'>";
    	$html .= "{$tag->name}</a>";}
    
    		
    		
    

    but it didn't work. is this even possible? thanks so much!

    http://identitywebandphoto.com/amydemo/wordpress/designs/
    December 27, 2015 at 11:18 pm #174918
    rfmeier
    Member

    carrieoke13,

    If I am correctly understanding what you are attempting to do, you can iterate through each page object and grab the associated terms with get_the_terms() and then use get_term_link() to generate the link.

    Let me know if I am not understanding the question correctly.

    Good luck!


    Ryan Meier – Twitter

  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2026 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble