Support » Fixing WordPress » Categories List broken by Permalinks

  • Resolved cmdshiftdesign

    (@cmdshiftdesign)


    Setting up a listing of Categories w/ their descriptions. All of the categories are within a custom post type named “works”

    I used this code and it worked PERFECTLY (ref: http://codex.wordpress.org/Function_Reference/get_categories#Default_Usage)

    <?php $args=array('orderby' => 'name','order' => 'ASC');
    		  		$categories=get_categories('taxonomy=works');
      				foreach($categories as $category) {
       				echo '<p><a href="' . get_category_link( $category) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a>: ';
    				echo ''. $category->description . '</p>';  }
    ?>

    BUT, once i changed my Permalink settings from it’s default: /?p=123 setting to the Post Name: /sample-post/ setting, the links that used link perfectly to the category pages broke.

    Any ideas how to solve this as I would prefer to use the Post Name permalink configuration!

Viewing 9 replies - 1 through 9 (of 9 total)
  • get_category_link() requires an ID, maybe try $category->ID because you’re just passing an object at this point.

    <?php $args=array('orderby' => 'name','order' => 'ASC');
    		  		$categories=get_categories('taxonomy=works');
      				foreach($categories as $category) {
       				echo '<p><a href="' . get_category_link( $category->ID) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a>: ';
    				echo ''. $category->description . '</p>';  }
    ?>

    FYI I don’t know if ID is a valid object type but it’s worth a try, I haven’t dumped the $category variable yet.

    Jerry, you look to be great at this, I have a related problem:
    pageslinks: I created on home additional pages (besides Home), like preferences etc. The link is always like: blog.mypage.sk/preferences. I need it to be like: mypage.sk/preferences. I changed permalinks to pretty permalinks too, but this did make no change. I tried 2 PCs with IE, Chrome and Firefox, cant change anywhere. Please, advise where to change the link to what I need and how, which php file etc. Thanks

    Wow webstranka, you’re everywhere tonight 🙂

    feeling hopeless, cause trying for 3-4 days alone..that`s why..:(

    Check your original thread.

    Thread Starter cmdshiftdesign

    (@cmdshiftdesign)

    both what I had originally and with the ->ID addition Jerry suggested returns a link of the Categories Names but the link just points to the sites homepage, not the category archive. … UNLESS i switch to Default /?p=123 configured permalinks.

    Jerry, could u come back to my thread again? I really need your help to fix it back please, cause te change messed up the whole blog page. I already deleted it compeltly and copyed from backup, but still looks like the theme is lost and I can`t log in, cause get error with wp-login.php. Could you please find some time for me?

    Moderator cubecolour

    (@numeeja)

    webstranka, please do not hijack other peoples’ topics.

    Thread Starter cmdshiftdesign

    (@cmdshiftdesign)

    solved this by adding the custom post type name into the “Category base” field within WordPresses Permalinks Panel!

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Categories List broken by Permalinks’ is closed to new replies.