• 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

Custom Site Navigation in Sidebar

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 › Custom Site Navigation in Sidebar

This topic is: not resolved

Tagged: Sidebar, site nav

  • This topic has 1 reply, 2 voices, and was last updated 8 years, 4 months ago by vajrasar.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • May 9, 2015 at 9:29 pm #151377
    raisethebarr
    Member

    I am trying to set up site navigation in the sidebar such as seen on this site: http://www.gameaccessoriesguide.com/. When you click one of the pages, the right sidebar shows a "Site Topic" section which lists what it appears to be sibling pages. Below this, there's a section "Articles About This Topic" that seems to show the child pages of that current page. Then when you click through to a child page it shows the parent page in "Site Topic" and the current page and sibling pages in the "Articles About This Topic."

    Does anyone know of a plugin for this or a way to code this type of navigation into the sidebar? Thanks in advance,

    Ben

    http://www.highgroundgaming.com
    May 10, 2015 at 6:01 am #151425
    vajrasar
    Member

    The sidebar in right shows the latest posts in my opinion (not sibling pages) except it leaves the one you are on at the moment and shows other latest posts/pages. Following code will get you started.

    First, Enable php in widgets with this code in your functions.php -

    add_filter('widget_text','execute_php',100);
    function execute_php($html){
         if(strpos($html,"<"."?php")!==false){
              ob_start();
              eval("?".">".$html);
              $html=ob_get_contents();
              ob_end_clean();
         }
         return $html;
    }

    then paste this code in your primary sidebar in a text widget -

    <?php
    	global $post;
    	$p_id = $post->ID;
    	$p_id = array( $p_id );
    	
    	$args = array(
    		'post_type' => 'post',
    		'post__not_in' => $p_id,
    		'posts_per_page' => 5,
    	);
    	$side_args = new WP_Query( $args );
    
    	if ($side_args->have_posts()) {
    		?>
    		<ul>
    			<?php
    			while ($side_args->have_posts()) {
    				$side_args->the_post();
    				?>
    				<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    			<?php
    			}
    			?>
    		</ul>
    		<?php
    	}
    	?>

    change 'post_type' => 'post' to 'post_type' => 'page' if you want to show latest additions in pages.

    Articles about this topic is simple, as it can be done via Related post plugins (you can use tags in your posts to do so).


    I make WordPress websites using Genesis Framework.

    WordPress/Genesis Development | Customizations

  • 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

© 2023 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