[resolved] Can you echo a custom panel option value within a function? (5 posts)

  1. Jacorre
    Posted 4 years ago #

    Is it possible to echo the value of a custom panel option within a function?

    For example, if I'm using a query_posts function, can I pass in the values of a custom panel option to the argument of cat?

    Custom Panel Option Values = 1,2,3,4
    query_posts(cat=(echo values here))

    Same idea when using an if statement and in_category(array(echo values here)).


  2. David Gwyer
    Posted 4 years ago #

    Sure, you can do something like:

    // assign the variable as current category
    $categoryvariable = $cat;
    // concatenate the query
    $args = 'cat=' . $categoryvariable . '&orderby=date&order=ASC';
    // run the query
    query_posts( $args );

    See here for more examples:


  3. Jacorre
    Posted 4 years ago #

    Ah I was trying to echo right within the query posts instead of assigning the arguments as variables first. I'll give that a try thanks!

  4. Jacorre
    Posted 4 years ago #

    Doesn't seem to be working when using in_category(array($cats)).

    I have the following:

    $cats = get_option('mycats');
    if (!in_category(array($cats))) { ?>
  5. Jacorre
    Posted 3 years ago #

    Saw the mistake I was making thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic