• I’m trying to add a set of links to the sidebar of my pages, however, each page has a unique set of links (for instance, the About page would have a set of links and the Contact page would have its own set of links).

    The problem is that I have to create a new dynamic sidebar and template for each page which is troublesome and not ideal (or really an option) for a novice user (my client).

    I have attempted a few plugins but all require their own unique dynamic sidebar (basically, I really only want one sidebar). I have also attempted to get into the php code of the sidebar.php and have use the list_bookmarks code and a custom field value (for the link category id) but can’t seem to get that to work. Here is the code below (the c2c_get_custom comes from the Custom Fields plugin):

    <?php
    $linkCategory = c2c_get_custom(‘Category’);
    wp_list_bookmarks(‘category=$linkCategory’);
    ?>

    I may just have my php syntax wrong but if I can some how get the custom field value has a variable and list that in the wp_list_bookmarks category value, that would make my day.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Or, you could try…

    <?php if (is_page('About')) : ?> //the feed list page
    <ul><?php wp_list_bookmarks('category=2'); ?></ul>
    <?php endif; ?>

    Thread Starter th3wildcard

    (@th3wildcard)

    @jrav001 – a good method, but if someone wants to add a new page, someone would have to add a new line of code to the sidebar.php, which I’m trying to avoid. Basically, I want them to be able to add a page, but have that page have its own set of links from a set of link categories without having to do any coding on their end.

    Thread Starter th3wildcard

    (@th3wildcard)

    Is there something wrong with the syntax in my code perhaps?

    <?php
    $linkCategory = c2c_get_custom('Category');
    wp_list_bookmarks('category=$linkCategory');
    ?>

    Is $linkCategory returning a number? I believe wp_list_bookmarks is looking for an ID# and not a name.

    For troubleshooting, add an echo in there to see what is being returned.

    Thread Starter th3wildcard

    (@th3wildcard)

    $linkCategory doesn’t seem to be returning a value. Something wrong with my syntax? I know that c2c_get_custom(‘Category’) is returning a value after using the echo command.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Links per Page’ is closed to new replies.