• A site I’m developing uses posts as “news blocks” on custom page templates. Every spot can be edited using posts. It’s working well, except that my development site on my computer uses one set of category numbers for posts, but the actual site on another server uses another set of category numbers.

    I have to change the category numbers on the template filefor each news block every time before I upload an update to the “real” server. It can be a real hassle.

    My question is this… is it possible to use the category names instead of numbers in the code?

    So that instead of this:

    <?php $posts = get_posts( “category=10&numberposts=1” ); ?>

    I can use something like this:

    <?php $posts = get_posts( “category=categoryname&numberposts=1” ); ?>

    I try this, and it seems to default to the newest post I’ve created. So the name isn’t working, or I’m not using a proper PHP syntax. Or, it’s not possible.

    Thanks for any help.

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Use Category Names instead of Category Numbers?’ is closed to new replies.