The MU forums have moved to

Change 2 default links in wpmu-functions to 10 default links (5 posts)

  1. plainsman
    Posted 16 years ago #

    I've searched the forums re: default links in wpmu-functions.php and cannot find an answer to my question.

    I'm trying to cause new blogs to automatically create 10 links in the sidebar when their blog is initially created.

    The site is part of a larger community and I want those links to be present in each sidebar by default.

    I have found the area where the two (2) default links exist in wpmu-functions.php. But, when I edit them - and add other links below following the same code syntax, they do not show up.

    Obviously, I'm missing something. Can anyone tell me how to make them show up, please?

    Thank you.

  2. plainsman
    Posted 16 years ago #

    I should have noted that the links *do* get created, and show up in the blog's admin Blogroll section.

    But they do not get placed into the category Blogroll. They actually don't show any category as being assigned. This despite the coding of the new link matches the previous two.

    I thought that changing the link_count on line 1284 from "2" to "10" would do the trick, but it doesn't.

    	$wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, link_count, category_description) VALUES ('{$blogroll_id}', '".addslashes(__('Blogroll'))."', '".sanitize_title(__('Blogroll'))."', 2, '')");

    I am stumped.

    I thought that the change from 2 to 10 would do it as the same code appears in WP 2.1.1 in /wp-admin/upgrade-functions.php

    Seemed like the correct place to change the number of default links.

  3. drmike
    Posted 16 years ago #

    We talked about this awhile back. You are on the right track as to adding the category links as well.

    Open up wp-includes/wpmu-functions.php and look for the function install_blog. Go down a bit until you see the following:

    $wpdb->query("INSERT INTO $wpdb->link2cat (link_id, category_id) VALUES (1, $blogroll_id)");

    You have to dupe that line for each link you add in but increasing the link_id for each link. For example, to add in an additonal link, you would add in:

    $wpdb->query("INSERT INTO $wpdb->link2cat (link_id, category_id) VALUES (3, $blogroll_id)");

    Go down a bit more until you reach the function install_blog_defaults and put the link in as well:

    $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_owner, link_rss) VALUES ('', 'Dr. Mikes Blog', 1, '$user_id', '');");

    Hope this helps,

  4. plainsman
    Posted 16 years ago #

    Bingo! Worked like a charm.

    Thank you, drmike. Exactly what I needed.

    After looking at it with your guidance, the process *now* seems intuitive. You helped me learn. I appreciate it.

    Thanks. Take care.

  5. drmike
    Posted 16 years ago #

    Not a problem. :)

About this Topic

  • Started 16 years ago by plainsman
  • Latest reply from drmike