WordPress.org

Ready to get started?Download WordPress

Forums

exclude a category, with 'get_option' ... (2 posts)

  1. alsd
    Member
    Posted 4 years ago #

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

    <?php
    $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:

    query_posts("cat=-5");

    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

  2. MichaelH
    Member
    Posted 4 years ago #

    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')); ?>

Topic Closed

This topic has been closed to new replies.

About this Topic