WordPress.org

Ready to get started?Download WordPress

Forums

get_category_link just gives back the root-dir (2 posts)

  1. Nebaon
    Member
    Posted 7 years ago #

    I use a cool plugin from siteflickr to insert a random category and random posts out of this cat into my blog (see it working on the frontpage of http://www.bittekunst.de). The only problem is: The category isn´t linked yet. I wanted to change that by myself, but all I managed to do is to get known to the get_category_link-Function and that one always gives back a link to the root (www.bittekunst.de/category). I read on this reference site that the reason is a non-existing category ID. But I don´t get the point.

    So, here´s the original code of the plugin:

    function random_category_and_posts($type="ul", $beforeHead="h2", $afterHead="h2", $numPosts="5", $categoryID = '', $includeExcerpt=false, $customField="", $customValue="")
    {
    global $wpdb; // Global wordpress variables

    // set the default before and after values
    if ( $beforeHead == '' ) $beforeHead = 'h2';
    if ( $afterHead == '' ) $afterHead = 'h2';
    if ( $numPosts == '' ) $numPosts = '5';

    // Get a random category
    $category = random_category($categoryID);

    if ( $category['post_count'] < $numPosts ) {
    $numPosts = $category['post_count'];
    }

    $articles = random_posts($category['id'], $includeExcerpt, $numPosts, $customField, $customValue);

    // Display the category name
    $result = ("<" . $beforeHead . ">Was Neues? Zum Beispiel " . $category['name'] . ":</" . $afterHead . ">\n");

    My Change:
    I tried different things, e.g. inserted
    $the_cat_adress = get_category_link($category->cat_ID); just before the line which prints out the category-name (I inserted <a href=-command in that line). I tried it via direct-function call in that printing-line. I tried the Variables $category_id and $category. And I don´t know what to do know..

    Anybody knows?

    Thanks!
    David

  2. poosk
    Member
    Posted 7 years ago #

    need this...someone please

Topic Closed

This topic has been closed to new replies.

About this Topic