WordPress.org

Ready to get started?Download WordPress

Forums

Adding an entirely new Links Section (29 posts)

  1. gleem
    Member
    Posted 9 years ago #

    IS there a way to basically split my links admin into 2 panels? Like one would be called "Links" and the other would be called "Links Two"? This way I can keep safe for work links in it's own world and NSFW link in it's own dirty pig pen, and saves me from trying to nest em 3 times ( links>NSFW>SUBcategory)

  2. tomhanna
    Member
    Posted 9 years ago #

    If you have a not safe for works category, my suggestion would be...don't be on that blog at work in the first place, because somebody is going to follow your history there.

  3. gleem
    Member
    Posted 9 years ago #

    ehhh, that's besides the point, I was just using that as an easy example, I am my own boss and honestly don't care who gets busted ;)

  4. gleem
    Member
    Posted 9 years ago #

    *bump for the morning crew

  5. Ming
    Member
    Posted 9 years ago #

    Looks like I'm part of the morning crew.

    Check out http://codex.wordpress.org/Template_Tags/wp_get_links

    The short bits:
    1. Create a new link category using the admin interface
    2. Assign relevant links to that category
    3. use wp_get_links(category_number) in your sidebar to only show that category.

  6. gleem
    Member
    Posted 9 years ago #

    but that won't give me the same structure as the "links" in the sidebar, ie:

    Links
    -------
    Category
    >subcategory

    Links2
    ---
    Category
    >subcategory

    will it? guess I could just manually type in the name in the source.

  7. gleem
    Member
    Posted 9 years ago #

    ok, I almost have it with this:
    <?php get_linksbyname('Funny Sites' ); ?>

    except it won't display the subcategory the link is in, can't figure out how to tell it to do that, any ideas?

  8. iand
    Member
    Posted 9 years ago #

    Try:
    <?php _e('Funny Sites:'); ?>
    <ul>
    <?php wp_get_linksbyname('Funny Sites'); ?>
    </ul>

  9. Kafkaesqui

    Posted 9 years ago #

    As there's no parent<>child relationship for link categories in WordPress, could you explain what you mean by "subcategory."

  10. gleem
    Member
    Posted 9 years ago #

    I meant display the category name before the categories links, like I have 3 link in category "funny links" so I want this:

    Funny links
    link 1
    link 2
    link3

    and right it only displays the links with that code

  11. gleem
    Member
    Posted 9 years ago #

    basically my sidebar links will look like this:

    Safe for Work Links
    -------------------------
    Humor links
    link 1
    link 2
    link 3

    News links
    link 1
    link 2
    link 3

    Finance Links
    link 1
    link 2
    link 3

    NOT Safe For work links
    ------------------------------
    dating links
    link 1
    link 2
    link 3

    gross links
    link 1
    link 2
    link 3

    Sex Links
    link 1
    link 2
    link 3

  12. Kafkaesqui

    Posted 9 years ago #

    See example 2 at:

    http://codex.wordpress.org/Template_Tags/wp_get_links

    That provides a similar display for your links. You could then add a PHP if statement to check for which link categories appear in what group:

    <?php
    $link_cats = $wpdb->get_results("SELECT cat_id, cat_name FROM $wpdb->linkcategories");
    foreach($link_cats as $link_cat) {
    if($link_cat->cat_name != 'dating links') && ($link_cat->cat_name != 'gross links') && ($link_cat->cat_name != 'Sex links')) { ?>
    <li id="linkcat-<?php echo $link_cat->cat_id; ?>"><h2><?php echo $link_cat->cat_name; ?></h2>
    <ul>
    <?php wp_get_links($link_cat->cat_id); ?>
    </ul>
    </li>
    <?php }} ?>

    Just set up a version of this for each grouping of links.

  13. gleem
    Member
    Posted 9 years ago #

    I tried that and I get this error:
    Parse error: parse error,
    Unexpected T_BOOLEAN_AND
    in line 101

    which is the line with your PHP statement, and I don't know php enough to troubleshoot it :(

  14. gleem
    Member
    Posted 9 years ago #

    poop :(

  15. Kafkaesqui

    Posted 9 years ago #

    Just an oops on my part. Here's a redo of it, made it easier to read:

    http://guff.szub.net/source/fragment-26440.php

  16. gleem
    Member
    Posted 9 years ago #

    almost lol:

    Parse error: parse error, unexpected ':' in sidebar.php on line 100

    which is this bit:

    'Sex links')) : ?>

  17. lawtai
    Member
    Posted 9 years ago #

    just try removing the : and see what happens.

  18. gleem
    Member
    Posted 9 years ago #

    yeah, just gave another error in another spot when I did.

  19. lawtai
    Member
    Posted 9 years ago #

    change the : to ; (semi-colon)

  20. Kafkaesqui

    Posted 9 years ago #

    "change the : to ; (semi-colon)"

    No, don't do that.

    I've tested the linked version twice (now three times), and it should work...

    Ok, I've re-modified it (perhaps there was a PHP issue with the if/endif I was using).

  21. lawtai
    Member
    Posted 9 years ago #

    heh, looks like i still need more practice with my php coding

  22. gleem
    Member
    Posted 9 years ago #

    ok, I used your modified code, and got this error:
    "unexpected '{' in blah blah"
    it didn't like this " 'Sex links')) { ?>"

    so I removed it and then got
    "unexpected '}' in blah blah"
    it didn't like this "<?php } } ?> "

    so I removed that one and it just gave me a fatal error.

    I have a migraine, and have to crash, not sure what is wrong, I'll check back in the morning. I really appreciate your help though ;)

  23. Kafkaesqui

    Posted 9 years ago #

    In the morning if it still fails, stick the entire template up here:

    http://paste.uni.cc/

    And post the link given in a reply. That way we can get a good look at it.

  24. gleem
    Member
    Posted 9 years ago #

    not sure what you mean by sticking entire template up there?

    also, would post a link here, but the site is adult in nature, not sure if that's cool here.

  25. Kafkaesqui

    Posted 9 years ago #

    Template = file you are adding the PHP script I've placed here into.

    The code is most likely conflicting or breaking at some point, and unless it can be seen in place, it'll be nearly impossible to troubleshoot.

  26. gleem
    Member
    Posted 9 years ago #

    here is the area I'm putting it in
    http://paste.uni.cc/6762

  27. gleem
    Member
    Posted 9 years ago #

    can you see it?

  28. Kafkaesqui

    Posted 9 years ago #

    Yep.

    http://guff.szub.net/source/sidebar-26440.php

    Look for:

    <?php /* Start of links list code. */ ?>

    ~Script code is here.~

    <?php /* End of links list code. */ ?>

    I followed to a degree your example link category names above (which you'll no doubt need to modify), and set up two iterations of the code for the two sections.

    Also hit your permalinks issue while I was in there.

  29. gleem
    Member
    Posted 9 years ago #

    I get:

    <b>Parse error</b>: parse error, unexpected '{' in this line:

    if(($link_cat->cat_name != 'Dating') && ($link_cat->cat_name != 'Gross') && ($link_cat->cat_name != 'Sex')) { ?>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.