I have a Wordpress Sidebar menu that is becoming too long so I need just to have the menu items show and not the sub-items.
Does anyone know how to add folding menu subitems functionality to it please?
I am using a plugin called: wp-wiki and I have added:
<?php wp_list_pages('post_type=wiki'); ?>
So, I get a list of pages. That's all good but I don't want the subpages on the sidebar.php page, or at least not showing all the time.
Thanks
<?php wp_list_pages('post_type=wiki&depth=1'); ?>
Related
i everyone i have afew pages in wordpress that i need different custom right sidebars on with different css styles. for example i would like my homepage right sidebar to be a set width say 100px and displaying specific content and id like to have my special offers page with a right sidebar thats a different width say 230px displaying different content like widgets etc...
to my understanding this should be able to be achieved by creating custom sidebars by registering them with a wordpress function and then creating a custom sidebar template php file with a different css class for the sidebar. and then calling the new custom sidebar template file inside of a custom page template file being applied to a target page in wordpress so that the page loads the custom sidebar template instead of the normal sidebar template with a new css class that can be modified to achieve different sidebar styles for different pages. so i created the following custom sidebar template and called it customrightsidebar.php
<div id="sidebar3"><div class="sidebar3"><?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('customright-sidebar') ) : ?><div class="customright-sidebar"><h4>Recent Posts</h4><ul><?php wp_get_archives('type=postbypost&limit=5'); ?> </ul></div><?php endif; ?></div> <br style="clear:both"></div>
i then registered a new custom sidebar using this function
register_sidebar(array('name'=>'customright-sidebar','before_widget' => '<div class="customright-sidebar">','after_widget' => '</div>','before_title' => '<h4>','after_title' => '</h4>',));
and here is the custom page template that is calling the custom sidebar template
<?php get_header(); ?><div id="breadcrumb"><?php breadcrumbs(); ?></div>
<?php include(TEMPLATEPATH."/customrightsidebar.php");?>
<div id="kontenutama"> <div class="postingan2"><?php if (have_posts()) : while (have_posts()) : the_post(); ?><h2><?php the_title(); ?></h2><?php the_content(); ?><?php endwhile; else: ?> <p><?php _e('Sorry, no posts matched your criteria.'); ?></p><?php endif; ?><br style="clear:both;"></div></div>
<br style="clear:both"><div style="clear:both"></div><?php get_footer()?>
i successfully have a custom right sidebar that appears in my wordpress admin panel and i can apply widgets to it in the widgets section of my admin panel i can also see it appear in the custom sidebar dropdown selection menu in my wordpress pages where you would specify your new custom sidebars to overwrite the old ones. you can see a screenshot of the sidebar selection boxes in my theme by visiting this url
http://test.smartphonesource.org/sidebars.png
and normally by selecting it it would overwrite the default sidebars on the page
i have been able to get the custom sidebar template to load with the custom class on the page and ive been able to edit the css but the actual custom sidebar itself with its widgets isnt appearing or overwriting anything even though ive selected it to overwrite the right sidebar of the current page in the custom sidebars selection box
im not sure where to go from here or if there is a different way to do this i think somewhere the customsidebar isnt overwriting the default right sidebar when its been selected in the custom sidebar selection box on my pages im new to wordpress and php. ive been able to use the customright-sidebar on my videos page for testing and it successfully overwrote the right sidebar and worked but it was running this default right sidebar template
<div id="sidebar2"><div class="sidebar2"><?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Sidebar Right') ) : ?><div class="left-sidebar"><h4>Recent Posts</h4><ul><?php wp_get_archives('type=postbypost&limit=5'); ?> </ul></div><?php endif; ?></div> <br style="clear:both"></div>
anyhelp would be greatly appreciated figuring this out =) you can see the homepage of the site here that im using to learn wordpress and from there you can navigate to the videos and special offers page that im tearing apart to get a better idea of what im trying to do with the sidebars
http://test.smartphonesource.org
First of all, your website looks really awesome:) And to fix this did you make sure that your page is only grabbing the new sidebar code only?
i managed to fix the page issue im not sure what was wrong but it suddenly started working with the same code i know i cleared my cache so maybe that was affecting it or preventing the new changes from appearing sometimes if i dont clear the cache after i upload new images they wont display for me
I need to display several sidebars with custom context.
I suppose that I need to add several additional blogs to be displayed as sidebars. That is for every sidebar I am going to create a little specialized blog.
The question: How to make sidebars from a different blog to be displayed in a blog sidebar?
If you want to add more than one sidebar, you need to create sidebar for each blog and name it. E.g., want to create sidebar for aboutus.php (created as template page). Create sidebar as sidebar_aboutus.php and add what you want in sidebar to it.
Then include that sidebar_aboutus.php in your aboutus.php like this:
<?php
/**
* Template Name: About us
*
* Selectable from a dropdown menu on the edit page screen.
*/
?>
<?php get_header(); ?>
<?php include ('sidebar_aboutus.php'); ?>
<?php get_footer(); ?>
Likewise, you can create and include as many sidebars as you need for your different blog pages.
I have a couple of pages (home, about me, ...) in my main navigation. Now I'd like to get rid of my sidebar and I have plenty of space in my main navigation. Is there any chance I could get my categories to display in there, preferably with the subcategories displaying as childs (which will work well in the dropdown menu I have)?
Appreciated!
<?php wp_list_cats(); ?> will list your categories. It will however list them vertically so you'll need to use css in your style sheet to create a class to list the horizontally.
As for removing the side bar. If you go to your index.php and your single.php you will set something like <?php sidebar(); ?> or <?php get_sidebar(); ?> by removing this the page will no longer fetch your side bar. I would personally not advise deleting the sidebar.php file(if you have one) or deleting this line of code for formatting reasons. It is probably best to comment it out that way you can add it back if you ever decide you want a sidebar again.
How do you get children of primary links to output in the HTML? Only my parent-level primary links are generating LI's.
I have a very very simple two-level primary links menu. There are 5 pages on the site: three parents, and the third parent has two children. In the administrative menu settings I have the parents' and childen's 'expanded' checkbox checked.
I have tried adding all kinds of functions from stackoverflow (including Drupal 6: Printing Unadulterated Primary Links and all children) and drupal and elsewhere to template.php to get the children to output... nothing!
How do you make primary links expanded?? This seems like such a stupid question. Why wouldn't checking 'expand' checkboxes print the children?
A direct solution to your problem. For Drupal 6:
<?php
// gets whatever is set as the primary menu source,
// prints the whole tree,
// pays attention to expanded settings
$menu_name = variable_get('menu_primary_links_source', 'primary-links');
print menu_tree($menu_name);
?>
I then wrap that in a "primary" div id, in my page.tpl.php and page-front.tpl.php
Remember to set each menu item that has children to expanded if you want them to start laid out rather than collapsed. /admin/build/menu
This solution will take notice of your settings on this page: /admin/build/menu/settings
For more info see the Drupal 6 code on this page http://drupal.org/node/68578
The problem is displaying all the children of the primary menu, so the secondary menu is irrelevant, although it can be set to point to the 2nd level of the primary menu as the above link discusses.
I wasn't able to get primary links to print their children when using theme('links', $primary_links) in page.tpl.php regardless of configuration settings.
Instead, after hours of searching, I found this page on drupal.org which mentions that primary links will output differently depending on whether they're being used as links in a theme or as a block:
http://drupal.org/node/187932
It's a discussion about how primary links' 'expanded' option may appear as 'not working' when they are being used as a theme option instead of as a block. When used as a block, primary links will show the full hierarchy of the list you set up, including children. When used in the theme, unless you overwrite the default settings for how primary links display for your theme, it will only list the top-level primary links. This is what Mark mentioned as the default behavior above, and what I was experiencing.
To solve my issue, I simply took the code to print the menus out of the page template entirely, and then assigned primary links to the region in my template where the code was before.
so instead of:
<div id="nav">
<?php if ($primary_links): ?>
<div id="primary">
<?php print theme('links', $primary_links); ?>
</div>
<?php endif; ?>
<?php if ($secondary_links): ?>
<div id="secondary">
<?php print theme('links', $secondary_links); ?>
</div>
<?php endif; ?>
</div>
I now have:
<div id="nav">
<?php if ($navigation): ?>
<?php print $navigation ?>
<?php endif ?>
</div>
AND specified a region in my .info file for 'navigation',
AND went to the block settings and assigned 'primary links' to my new navigation region.
To get rid of extraneous code outputting into my new navigation region, I also created a new block template for this region that just outputs the content of the block without any additional wrapping divs or heading tags. I ended up with a navigation unordered list that is pretty tidy, and I hope anyone else who is new to drupal and struggles with this issue finds my personal work-around helpful.
How primary links display is dependent on your theme. Without knowing more about your theme and how it implements primary links, it'd be impossible to say for sure why your primary links aren't expanding.
One thing you could check is the menu settings; in many themes, the second level is a separate menu called Secondary links. You can change this functionality by going to http://example.com/admin/build/menu/settings and setting Source for the secondary links to Primary links: this will display the second level of the primary links menu instead of the (likely empty) secondary links menu.
This brilliant blog post tells you exactly how you can get the entire tree structure for your primary links (including children) programmatically, and even shows you a way of tidying up this structure for easier use.
http://jamesmorrish.co.uk/blog/get-a-clean-array-of-primary-links-in-drupal/
I believe the Menu block module does what you are looking for. Some more details about this module (from its project page):
So… have you ever used the Main and Secondary menu links feature on your theme and wondered “how the hell do I display any menu items deeper than that?”
Well, that’s what this module does. It provides configurable blocks of menu trees starting with any level of any menu. And more!
So if you’re only using your theme’s Main menu links feature, you can add and configure a “Main menu (levels 2+)” block. That block would appear once you were on one of the Main menu’s pages and would show the menu tree for the 2nd level (and deeper) of your Main menu and would expand as you traversed down the tree. You can also limit the depth of the menu’s tree (e.g. “Main menu (levels 2-3)”) and/or expand all the child sub-menus (e.g. “Main menu (expanded levels 2+)”).
Just playing around with Wordpress 3.0 for the first time. I've installed the Custom Post Type UI plugin, and have created a custom post type: "composers".
How do I go about creating a navigation menu for all the composers? Ideally, I'd like a static page entitled 'composers' which has a nav menu of all the individual composers.
In the Appearance -> Menus page, I can create a menu and assign composers individually to it, but what do I need to do to just add the entire collection of composers to a menu, so that it updates when I add a new composer? Surely I don't have to add them all manually?
What you're trying to do might be better achieved as a plugin, or a little editing in your theme file, something along the lines of;
$composers = new WP_Query('post_type=composers');
if ($composers->have_posts():
?>
<ul class="composer-nav">
<?php while ($composers->have_posts()): $composers->the_post(); ?>
<li>
<?php the_title(); ?>
</li>
<?php endwhile; ?>
</ul>
<?php endif; ?>
I know the idea behind custom menus was to try and avoid the need for plugins or theme editing, but I think it was truly designed for users to be able to pick and choose exactly what they wanted, rather than automatically listing items (just my opinion).