Sidebar med länkar till undersidor

Sidebar med länkar till undersidor


Warning: WP_Syntax::substituteToken(): Argument #1 ($match) must be passed by reference, value given in /home/mankitse/designoak.com/wp-content/plugins/wp-syntax/wp-syntax.php on line 380

Warning: WP_Syntax::substituteToken(): Argument #1 ($match) must be passed by reference, value given in /home/mankitse/designoak.com/wp-content/plugins/wp-syntax/wp-syntax.php on line 380

Warning: WP_Syntax::substituteToken(): Argument #1 ($match) must be passed by reference, value given in /home/mankitse/designoak.com/wp-content/plugins/wp-syntax/wp-syntax.php on line 380

Warning: WP_Syntax::substituteToken(): Argument #1 ($match) must be passed by reference, value given in /home/mankitse/designoak.com/wp-content/plugins/wp-syntax/wp-syntax.php on line 380

Warning: WP_Syntax::substituteToken(): Argument #1 ($match) must be passed by reference, value given in /home/mankitse/designoak.com/wp-content/plugins/wp-syntax/wp-syntax.php on line 380

Här är ett tips för dig som vill skapa en sidopanel med länkar till de aktuella undersidorna. Rubriken blir den sida som är överst i hierarkin och under listas undersidorna. Ett exempel på hur det kan se ut kan du se här: http://www.scandcap.se/tjanster/. Även rubriken är klickbar när du är inne på undersidorna, detta gör att det är lätt att komma tillbaka till ”huvudsidan”. Koden kan placeras i sidebar.php eller om du väljer att ha den i ditt page template. Såhär ser koden ut för att skapa denna funktion:

<!--?php //parent variables 	$parent = get_post($post--->post_parent);
	$parent_title = get_the_title($parent);
	$grandparent = $parent-&gt;post_parent;
	$grandparent_title = get_the_title($grandparent);?&gt;
 
	<!--?php // is the homepage the granparent? 	if ($grandparent == is_page('0')) { ?-->

	<!--?php // is the homepage the parent? 	} elseif ($post--->post_parent ==is_page('0')) {?&gt;

    <!--?php // I must be a top level page! 	} else { ?-->

    <!--?php }?-->
 
	<!--?php if(!$post--->post_parent){
	// will display the subpages of this top level page
	$children = wp_list_pages("title_li=&amp;child_of=".$post-&gt;ID."&amp;echo=0");
}else{
	// diplays only the subpages of parent level
	//$children = wp_list_pages("title_li=&amp;child_of=".$post-&gt;post_parent."&amp;echo=0");
 
	if($post-&gt;ancestors)
	{
		// now you can get the the top ID of this page
		// wp is putting the ids DESC, thats why the top level ID is the last one
		$ancestors = end($post-&gt;ancestors);
		$children = wp_list_pages("title_li=&amp;child_of=".$ancestors."&amp;echo=0");
		// you will always get the whole subpages list
	}
}
 
?&gt;
     

    Lämna ett svar


    @fontface Apache Bygg ditt eget tema Cache cms Databas FTP Färg Färgpalett GitHub Go Grafisk formgivning Grafisk identitet Grafisk profil Grunge ikoner Inspiration JavaScript kod Kreativitet Logotyp Länkbyggnad mall Media Queries Minimalism Multisite Nyckelord php python Responsivt ruby SEO symmetri Säkerhet Sökord Tips & tricks Trender Typografi Typsnitt Visitkort Webbdesign Webbhotell webbshop Webbutveckling WordPress