Reputation: 10046
So I have the following code:
<?php
query_posts("order=ASC&cat=4");
?>
<?php if(have_posts()): while(have_posts()): the_post(); ?>
<?php if(get_post_custom_values("show") != NULL): ?>
<?php
$categories = get_cat_ID(get_the_title());
$url = get_category_link($categories);
?>
<li class="thumb">
<a href=""><?php the_post_thumbnail(array(215,200)); ?></a>
<h2><a href=""><?php the_title(); ?></a></h2>
</li>
<?php endif; ?>
<?php endwhile; endif; ?>
</ul>
This code works, but when you have & -
in your title $categories = get_cat_ID(get_the_title());
.. get_cat_ID
won't work, do you know a work around?
Upvotes: 0
Views: 140
Reputation: 2567
Try get_category_by_slug
instead. Fetching the ID by the name of the category will get messy, especially with duplicates and characters, as you've discovered.
Upvotes: 1