can blogs url's and Titles be exported in a CSV, XML, or other type format?

I want to export all my blog URL's, Blog Titles, that are on the entire network!

Is this possible??

  • maxaud
    • The Crimson Coder

    create a file in /wp-content/mu-plugins/ called csv-blogs.php and add the following to that file:

    <?php
    /*
    Plugin Name: CSV Blogs
    Plugin URI:
    Description: Outputs names and urls of blogs in multisite
    Author: Dustin Dempsey
    Version: 1.0
    Author URI: http://www.playforward.net
    Network: true
    */
    	// create menu
    	add_action( 'admin_menu', 'CSV_plugin_menu' );
    
    	// add options page
    	function CSV_plugin_menu() {
    		add_options_page( 'CSV Blogs', 'CSV Blogs', 'manage_options', 'csv-blogs', 'csv_blogs' );
    	}
    
    	// page output
    	function CSV_blogs() {
    
    		// restrict to  those that can manage options
    		if ( !current_user_can( 'manage_options' ) )  {
    			wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
    		}
    
    		// out page content
    		echo '<div class="wrap">';
    
    			// get global DB
    			global $wpdb;
    
    			// Query all blogs from multi-site install
    			$blogs = $wpdb->get_results("SELECT blog_id,domain,path FROM " . $wpdb->base_prefix . "blogs ORDER BY blog_id");
    
    			// Start unordered list
    			echo '<ul>';
    
    			// For each blog search for blog name in respective options table
    			foreach( $blogs as $blog ) {
    
    				// Query for name from options table
    				$blogname = $wpdb->get_results("SELECT option_value FROM " . $wpdb->base_prefix . "".$blog->blog_id ."_options WHERE option_name='blogname' ");
    				foreach( $blogname as $name ) { 
    
    					// Create bullet with name and url
    					echo '<li>';
    
    					echo $name->option_value . ',';
    					echo $blog->domain;
    					echo $blog->path;
    
    					echo '</li>';
    
    				}
    			}
    
    			// End unordered list
    			echo '</ul>';
    
    		echo '</div>';
    	}
    ?>

    In the backend (/wp-admin/options-general.php?page=csv-blogs) under settings you'll have a new option called CSV blogs where the list of blog names and URLs are output.

  • Mark Wallace
    • Learn-ing-er

    Hi @maxaud

    A little trouble here!

    I do not have a MU-plugin folder only a plugin folder

    I first created a folder name csv-blogs.php then added that file to it.

    I have corrected that and placed the file in the wp-content/plugin folder.

    I do not see the

    In the backend (/wp-admin/options-general.php?page=csv-blogs) under settings you'll have a new option called CSV blogs where the list of blog names and URLs are output.

  • Mark Wallace
    • Learn-ing-er

    Ok this is really close to what i need.

    Alaska Classifieds,akclassifieds.mtb1701.com/

    Is there a way to make the url the first field and the site tile the second
    eample:

    akclassifieds.mtb1701.com/,Alaska Classifieds

    Please advise!

    When is your membership due for renewal???

  • maxaud
    • The Crimson Coder

    See in the file where it says

    // Create bullet with name and url
    echo '<li>';
    echo $name->option_value . ',';
    echo $blog->domain;
    echo $blog->path;
    echo '</li>';

    Make that..

    // Create bullet with name and url
    echo '<li>';
    echo $blog->domain;
    echo $blog->path . ',';
    echo $name->option_value;
    echo '</li>';
  • Mark Wallace
    • Learn-ing-er

    Thank you thank you thank you!

    I have been needing this for sometime now, It is truly an answer to a prayer!

    I will follow you via tags, any time you help another member i will give you points.

    If you do not have the other 9 individual gifted points to go along wit it, then I will cover 50% of your renewal cost. :slight_smile:

    So keep helping out, and we will get you there. Save this thread and post the threads you help people on, and i will give you points as well. This way it does not slip my mind, (If that were possible)

    As you help other members People like @Dean Kaus @Aristath @Mason @Arun Basil Lal @Kimberly @PC @Timothy @aecnu @Patrick and many others will see and reward you too!

    Again! Thank You Thank You Thank You Thank You
    Be Blessed!

  • Mark Wallace
    • Learn-ing-er

    Keep your eye on tom.eagles too! he is a helper!

    What was the meaning of the PK?

    It is a private "Title" (like a nick name that identifies a task or position) I am afraid i cannot share just yet. Probably never public. It was a goof!!!

    Also how do you follow by tags? I thought that I had that set up but not working for me.

    In the search you can use peoples names, it might not be a "tag", but it works lol

    Like for me i just type MTB in the search and get all the threads i ever started and commented on, the list has grown so much, that i started saving everything to text doc and placing them in folders for future reference. I have even created my Standard reply text doc, for common questions. lol

  • Mark Wallace
    • Learn-ing-er

    (this is a hint for @James) Customer service, tracking and or project management (keeping everyone on track and accountable)

    If that was a hint, what would a request be? PMSL

    I have always found it best to be forward and just ask. I am immune to the word NO; it only mean reevaluate and try again!

    So send a email to the following link:
    (this is a hint for @James) Customer service, tracking and or project management (keeping everyone on track and accountable)

    Attention it to @James or @Mason and say

    Hey, you fella's got a job for me; If not here are the positions you can create to will utilize my experience. Then sale yourself to them. If they say NO! then wait for a need that you can fill! Then ask again.

    The key to success in life, both financially and community is to find a need and fill it! Don't worry about competing, Make others compete with you, so if something lacks; improve it, if something is missing; create it. A person / business cannot fail following these principles.

    If you go for a job interview or try to get a client, study them, see how they dress, and match it, hear the words they use; and learn to use those words too. Surround yourself with what you want to be.

    I have seen people mistake you as staff here, so you are not to far off. :slight_smile:

    Sorry all, i should become a blogger or something. lol :slight_smile:

  • Mason
    • DEV MAN’s Sidekick

    And just to add to this, 6 of 7 of our Support staff (and a few of our developers as well) were previously members before being hired.

    Several members here do outstanding volunteer work here and participate by providing stellar support. If you think we don't notice... we might just surprise you :wink:

  • Mark Wallace
    • Learn-ing-er

    @tom.eagles

    The problem with this is, i need to be able to past the export file to a word doc, and highlight the top level domain use the Ctrl + F function to replace the top level domains URL with the next websites URL.

    Now that i have the blog url and title export i can create multiple multisites, dividing state and county with a breeze. I can then use the batch creator to import all these blogs, But i need to be able to make the Counties as "custom links" in sidebar widgets for each state.

    Is there a way to do this with the " export sql query"???

  • Mark Wallace
    • Learn-ing-er

    BUT if there is a way to turn blog titles and URLs into "custom links" for the widget, then that is huge for me!

    I am sure that anyone making a classifieds or directory on a multisite can see the advantage to this, or any other multisite that needs to break up information in this fashion.

    SUGGESTIONS are welcome!!! :slight_smile:

  • maxaud
    • The Crimson Coder

    I created a few few multi-city type sites and used placeholders for city names like {city_name} and then used WordPress's translator and some WordPress filters to replace this with the current blog's city name that was pulled from a WordPress option.
    Not too difficult and no titles needed changed and the URLs simply didn't contain the city name.

  • Mark Wallace
    • Learn-ing-er

    @MTB1701 You would need something along the lines of this as an export sql query..

    A text document can be saved as any document, correct?

    So in therory i could past the sql file in a text doc /word doc use the Ctrl + F feature in word to replace the domain URL's, but i still have to find a way to import them as "Custom Links" to create the widget menu!

    I believe in Capitalism, my email is in my WPMU Dev profile. :slight_smile:

  • maxaud
    • The Crimson Coder

    Where would this go {city_name}

    This is just an example placeholder in this case. In my case I search for this in the titles of posts and pages, option values (blogname), menu links, post content, and replace it with a value that is saved for the currently viewed site.

    WordPress filters ???

    WordPress filters pass information to a function you define before passing them back for display on the screen. You can manipulate the data if needed. In this case, we get the data and replace {city_name} in the string and return it back with how we currently want to display it depending on what blog we're on.
    See: http://codex.wordpress.org/Plugin_API
    See: http://codex.wordpress.org/Plugin_API/Filter_Reference

    WordPress option ???

    WordPress options are key-value-pairs that are saved in the wp_options table for the current site.
    See: http://codex.wordpress.org/Option_Reference
    Adding Option: http://codex.wordpress.org/Function_Reference/add_option
    Updating Option: http://codex.wordpress.org/Function_Reference/update_option
    Getting Option: http://codex.wordpress.org/Function_Reference/get_option
    Deleting Option: http://codex.wordpress.org/Function_Reference/delete_option

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.