WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Categories List broken by Permalinks (10 posts)

  1. cmdshiftdesign
    Member
    Posted 2 years ago #

    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!

  2. Jerry
    Member
    Posted 2 years ago #

    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.

  3. webstranka
    Member
    Posted 2 years ago #

    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

  4. Jerry
    Member
    Posted 2 years ago #

    Wow webstranka, you're everywhere tonight :)

  5. webstranka
    Member
    Posted 2 years ago #

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

  6. Jerry
    Member
    Posted 2 years ago #

    Check your original thread.

  7. cmdshiftdesign
    Member
    Posted 2 years ago #

    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.

  8. webstranka
    Member
    Posted 2 years ago #

    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?

  9. cubecolour
    ɹoʇɐɹǝpoɯ
    Posted 2 years ago #

    webstranka, please do not hijack other peoples' topics.

  10. cmdshiftdesign
    Member
    Posted 2 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic