The MU forums have moved to WordPress.org

Plugin: Add Global Page (Return to Main Site Link) (1 post)

  1. Driftless1
    Member
    Posted 14 years ago #

    I distilled this down from the Page-lists-plus plugin for WP -- a great plugin that was the sledgehammer to my mosquito.

    This adds a top-level link back to the MU-Central blog (blog #1) on all sub-blogs at the end of the wp_list_pages() function. Just plop it in mu-plugins directory.

    <?php
    
    add_filter('wp_list_pages', 'page_lists_plus');
    
    function page_lists_plus($output) {
    	global $wpdb;
    	$posts_table = $wpdb->prefix . 'posts';
    
    		if (stristr($output, '<li class="pagenav">') != FALSE) {
    			$output = substr_replace($output, '<li class="page_item"><a href="' . get_blogaddress_by_id( 1 ) . '">' . get_blog_details( 1 )->blogname . '</a></li></ul>', strrpos($output, '</ul>'));
    		} else {
    			$output .= '<li class="page_item"><a href="' . get_blogaddress_by_id( 1 ) . '">' . get_blog_details( 1 )->blogname . '</a></li>';
    		}
    
    	return $output;
    	}
    ?>

About this Topic

  • Started 14 years ago by Driftless1