wp_list_pages Hierarchical Help

After you global $post, you can use the core WordPress function get_post_ancestors() to retrieve the parent pages. Example $ancestors = get_post_ancestors($post); if($ancestors){ foreach(array_reverse($ancestors) as $post_id){ $ancestor_page = get_post($post_id); } } Then, to retrieve all child pages of the current page, you could make it easy by using a custom function. Place your custom function in … Read more

Make next post button link to random post

The code you posted does nothing but display. The code you need to alter is whatever is creating $prevID and $nextID, but that might not be entirely relevant. Basically, you just need to grab a random post. $rl = new WP_Query( array( ‘posts_per_page’ => 1, ‘orderby’ => ‘rand’, ‘fields’ => ‘ids’ ) ); ?> <div … Read more

Custom ul class

Menu class is nav navbar-nav not collapse navbar-collapse navbar-ex1-collapse. wp_nav_menu(array(‘theme_location’ => ‘primary’, ‘menu_class’ => ‘nav navbar-nav’));

Can’t get the previous and next posts permalink

You could use different code. As an example, this modified code from the Twenty Fourteen parent theme which i tested on other themes works well. Add this to a new file named template-tags.php <?php if ( ! function_exists( ‘wpsites_post_nav’ ) ) : function wpsites_post_nav() { $previous = ( is_attachment() ) ? get_post( get_post()->post_parent ) : … Read more

Odd spacing in Navigation Bar [closed]

That issues is often encountered when using inline-block on elements. Could be fixed with a good CSS reset when starting the theme (may force you to rewrite lots of css sections) or by making the menu “li” elements display block and float left instead. Check my screenshot how I “fixed” your problem. image link

How to get main menu only with wp_nav_menu

You can use the depth parameter like this: wp_nav_menu( array( ‘menu’ => ‘header-uk’, ‘menu_id’ => ‘nav’, ‘menu_class’ => ‘sitemap’, ‘fallback_cb’ => false, ‘depth’ => 1, ) ); Or if what you want to do is grab all items to create your own loop/output you can do that as well. Example: if ( ( $locations = … Read more

Custom navigation menu with awsAccordion

After reading PHP and wordpress codex i achieved what i wanted, by making a walker class. Here is the code class Hambos_Walker_Nav_Menu extends Walker_Nav_Menu { function start_lvl( &$output, $depth = 0, $args = array() ) { $indent = str_repeat(“\t”, $depth); if ($depth == 0): $output .= “\n$indent <div>\n”; else: $output .= “\n$indent <ul>\n”; endif; } … Read more

posts_nav_link pulling in multiple post types

query_posts should be avoided at all costs. This is not just my emphasis, but the codex’s as well Note: This function isn’t meant to be used by plugins or themes. As explained later, there are better, more performant options to alter the main query. query_posts() is overly simplistic and problematic way to modify main query … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)