Change page name in admin list

You can use the_title hook to change the title of the post in the admin, something like this add_filter( ‘the_title’, ‘custom_post_title’, 10, 2 ); function custom_post_title( $title, $post_id ) { // Return early if not in the admin if ( !is_admin() ) return $title; $post_type = get_post_type( $post_id ); // You only need to change … Read more

Single-page wordpress theme navigation

I’ve done a few templates that essentially are on one page. I used this code as the starting block for all of them: <?php $my_wp_query = new WP_Query(); $all_wp_pages = $my_wp_query->query(array(‘post_type’ => ‘page’,’posts_per_page’ => -1)); foreach ($all_wp_pages as $value){ $post = get_page($value); $slug = $post->post_name; $title = $post->post_title; $content = apply_filters(‘the_content’, $post->post_content); }; ?> It … Read more

Exclude pages by menu order

Declare the following function in your functions.php function wpse58346_wp_list_pages( $pages, $r ) { foreach( $pages as $key => $page ) { if ( 50 < $page->menu_order ) unset($pages[$key]); } return $pages; } Now before calling wp_list_pages() apply a filter as follows add_filter(‘get_pages’, ‘wpse58346_wp_list_pages’, ”, 2); And after you have called wp_list_pages() you can remove the … Read more

Add Parent to Subpage List

<?php if($post->post_parent){ $children = wp_list_pages(“title_li=&include=”.$post->post_parent.”&echo=0″); $children .= wp_list_pages(“title_li=&child_of=”.$post->post_parent.”&echo=0″); } else { $children = wp_list_pages(“title_li=&include=”.$post->ID.”&echo=0″); $children .= wp_list_pages(“title_li=&child_of=”.$post->ID.”&echo=0″); } if ($children) { ?> <ul class=”subpages”> <?php echo $children; ?> </ul> <?php } ?> Try that. Just have to include the parent much like you do on the child pages, but using the current $post-ID.

Hide Parent if No Children

<?php if ($post->post_parent) { //We are a child, print out sub menu wp_list_pages( array(‘title_li’=>”,’include’=>$post->post_parent) ); wp_list_pages( array(‘title_li’=>”,’depth’=>1,’child_of’=>$post->post_parent) ); } //We are not a child but do we have children $children = wp_list_pages(array(‘child_of’ => $post->ID, ‘echo’ => 0)); if ( !empty($children) ) { //If so print out the sub menu wp_list_pages( array(‘title_li’=>”,’include’=>$post->ID) ); wp_list_pages( array(‘title_li’=>”,’depth’=>1,’child_of’=>$post->ID) ); … Read more

Post Fetching Ignoring Sort_Column?

I’m not sure why you use the sort_column parameter, it’s not supported by the WP_Query() class. According to the Codex, the correct way to sort, is to use the order and orderby parameters. Please try this: $args = array( ‘post_type’ => ‘page’, ‘orderby’ => ‘menu_order’, ‘order’ => ‘ASC’, // DESC is the default order ‘post_status’ … Read more

Display custom post types in wp_list_pages

To simplify things, first make your archives actual Archives – not Pages. That will help you later on in listing the correct content. unregister_post_type(‘blog’); unregister_post_type(‘event’); unregister_post_type(‘news’); Unregistering the post type won’t delete any content, it will just ensure that when you re-register them, the settings will take effect. Tweak your register_post_type calls which should look … Read more

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