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.
Thread Starter
gleem
(@gleem)
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 π
Thread Starter
gleem
(@gleem)
*bump for the morning crew
Looks like I’m part of the morning crew.
Check out http://codex.ww.wp.xz.cn/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.
Thread Starter
gleem
(@gleem)
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.
Thread Starter
gleem
(@gleem)
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?
Try:
<?php _e('Funny Sites:'); ?>
<ul>
<?php wp_get_linksbyname('Funny Sites'); ?>
</ul>
As there’s no parent<>child relationship for link categories in WordPress, could you explain what you mean by “subcategory.”
Thread Starter
gleem
(@gleem)
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
Thread Starter
gleem
(@gleem)
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
See example 2 at:
http://codex.ww.wp.xz.cn/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.
Thread Starter
gleem
(@gleem)
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 π
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
Thread Starter
gleem
(@gleem)
almost lol:
Parse error: parse error, unexpected ‘:’ in sidebar.php on line 100
which is this bit:
‘Sex links’)) : ?>