Support » Plugins and Hacks » Hacks » change ?cat= to be able to pick up the permalink

  • Hi,

    I need to change this line of code so instead of it being example.com/?cat=1 its example.com/categoryname/postname . Permalinks was changed to %postname% and the category base was also changed. But this line is in the home-page.php of the theme

    <li><a class="arrow-aligned-left" href="<?php echo get_bloginfo('url') . '?cat=' . $category->term_id; ?>">&nbsp;&nbsp;&nbsp;<?php echo $category->name; ?></a></li>

    Thank You

Viewing 5 replies - 1 through 5 (of 5 total)
  • So, I don’t know if I understand exactly what you’re asking. This line of code seems to display a full category, but you want it rewritten to include a post name as well? Can you show me the SQL query that populated $category please?

    That was bad on my part. Sry. It displays example.com/?cat=1 I would like it to display example.com/category/categoryname/

    Thanks

    Okay, try this:

    <li><a class="arrow-aligned-left" href="<?php echo get_bloginfo('url') . '/' . $category->name . '/' . $category->slug ?>">&nbsp;&nbsp;&nbsp;<?php echo $category->name; ?></a></li>

    That will show:
    /My Category/my-category/

    you can replace the variables after the -> with any of these term_id for the number, name for the full name as it appears on the page and slug for the wordpress site name with dashes and such.

    Does that answer your question?

    Ty, Just about works.

    So instead of example.com/restaurants/italian/ – I renamed the category base.

    It displays example.com/Italian/italian/

    Thanks

    I just ended up hard coding it, well actually a friend gave the code.

    <li><a class="arrow-aligned-left" href="<?php echo get_bloginfo('url') . '/restaurant/' . $category->slug ?>/">&nbsp;&nbsp;&nbsp;<?php echo $category->name; ?></a></li>

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘change ?cat= to be able to pick up the permalink’ is closed to new replies.