Support » Fixing WordPress » exclude a category, with ‘get_option’ …

  • alsd


    In my index page I have this code to exclude a category (e.g. Breaking News) which is ID #5:

    $page = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1;
    query_posts(“cat=-5”); ?>

    I want to offer user to be able to enter the cat ID from the admin theme option. In my ‘theme-options-init’ file I have this :

    $options[] = array( “name” => “Exclude Breaking News ID”,
    “desc” => “Enter the id of Breaking News here. example:5”,
    “id” => $shortname.”_bn_id”,
    “std” => “”,
    “type” => “text”);

    My problem is that what I should insert in here:


    I tried something like this but it breaks my theme.

    query_posts(“cat=-<?php echo get_option(‘alsd_bn_id’); ?>”);

    Can a kind soul tells me what I did wrong? Thanks

Viewing 1 replies (of 1 total)
  • MichaelH


    What happens if you just do this?

    <?php echo 'this is my option' . get_option('alsd_bn_id'); ?>

    If you can display your option, then this should work:

    <?php query_posts('cat=-'. get_option('alsd_bn_id')); ?>

Viewing 1 replies (of 1 total)
  • The topic ‘exclude a category, with ‘get_option’ …’ is closed to new replies.