Listing Sub-Pages & Sub-Sub-Pages

So it turns out to be a bit easier than I thought: <?php if ($post->post_parent) { $ancestors=get_post_ancestors($post->ID); $root=count($ancestors)-1; $parent = $ancestors[$root]; } else { $parent = $post->ID; } ?> <?php $args = array( ‘depth’ => 0, ‘date_format’ => get_option(‘date_format’), ‘child_of’ => $parent, ‘title_li’ => __(”), ‘sort_column’ => ‘menu_order, post_title’ ); ?> <ul> <?php wp_list_pages( $args … Read more

How to add a menu that belongs to parent blog to all child-blogs?

Well, thanks to @toscho … For your help I found a way to achieve show the primary nav that belongs to parent blog to all child blogs: /** * Plugin Name: Network Primary Nav * Network: true */ add_filter( ‘wp_nav_menu_objects’, ‘network_primary_nav’, 100, 2 ); function network_primary_nav( $menu_items, $args ) { global $blog_id; $menu_name=”primary”; if ( … Read more

Costum walker with sub menu item count

Inside the function your $x is local. You might want to use a static variable: class Walker_Nav_Menu_Costum extends Walker_Nav_Menu { static $x = 0; function end_el( &$output, $item, $depth = 0, $args = array() ) { if ( 1 == $depth ) self::$x++; $output .= “<!– x:”.self::$x.”–>”; $output .= “</li>\n”; } }

Customizing a permalink

try this: <h2 class=”featured-title”><a href=”http://siteurl.com/category/<?php echo strtolower(str_replace(” “,””,$arr[$i][“title”])); ?>”><?php echo esc_html($arr[$i][“title”]); ?></a></h2>

Possible to hide Page if no posts from a CPT?

So I’ve come up with a solution – although I am not sure if this is the best, as it outputs CSS, something I prefer not to do. In the header.php of the theme: <?php $published_posts = wp_count_posts(‘CPT1’)->publish; if ( $published_posts == 0 ): echo ‘<style>.page-item-8{display:none;}</style>’; endif ?> <?php $published_posts = wp_count_posts(‘CPT2’)->publish; if ( $published_posts … Read more

New Page Position

To add a custom hash to the end of each URL added through the menu backend is easier said than done. You could build a custom walker. Or you could try to hook in the walker_nav_menu_start_el filter and edit just that, perhaps like so[nav-menu-template.php]: add_filter( ‘walker_nav_menu_start_el’, ‘my_skip_to_nav’, 10, 4 ); function my_skip_to_nav( $item_output, $item, $depth, … Read more

New posts label category with “new”

In case anyone else is looking for this in the future, turns out the best way to do it is by using wp_get_recent_posts function. Someone knocked up an example that worked great for me: <?php $args = array( ‘numberposts’ => ‘1’ ); $recent_post = wp_get_recent_posts( $args ); if (strtotime($recent_post[0][‘post_date’]) > strtotime(‘-7 days’)) $class = “new!”; … Read more

Add ID to target navigation link

I wasn’t able to find something that would add an id, but I did find something that would give me a class…this way I can target the class using jQuery. The default id’s and classes are ok, but the solution I found is much better because no matter which website you apply it to it … Read more

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