• I know this is asking a lot…. but is it possible to create an “if” (or whatever works..) statement that would allow me to use the Custom Field’s key data to point to the sidebar?

    I have probably 100 categories and will have 10,000+ pages with 100 different sidebars and I sure don’t want to keep adding to what I’m doing now which is:

    <?php if (is_single(7)) {include (‘sidebars/sidebar5.php’); }
    else if (is_single(10)) {include (‘sidebars/sidebar3.php’); }
    else {include (‘sidebars/sidebar.php’); }
    ?>

    and

    <?php if (is_category(5)) {include (‘sidebars/sidebar5.php’); }
    else if (is_category(3)) {include (‘sidebars/sidebar3.php’); }
    else if (is_category(7)) {include (‘sidebars/sidebar3.php’); }
    else {include (‘sidebars/sidebar.php’); }
    ?>

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter soleman

    (@soleman)

    I guess the only thing I need is an include with the post ID and the post ID’s meta tag for the category.

    In each post I’ll put a key named “sidebar” and the value will be the sidebar number.

    I just don’t know how to write this…..

    Thread Starter soleman

    (@soleman)

    Or maybe an easier way would be to put a key as “side” and the value as “/sidebars/sidebarXXX.php” (whichever sidebar corresponds to that post).

    Would that work…? And can someone help with the syntax as I’ve tried 100 ways and I just can’t get it. Started with something that didn’t have a chance…. <?php {include (‘<?php echo get_post_meta($post->ID, “side”, $single = true); ?>’); }
    ?>

    and it didn’t get any better from there….!

    Thread Starter soleman

    (@soleman)

    I can’t think of any other angle to go at this. Just tough with my limited coding skills… like mad limited – !

    Thread Starter soleman

    (@soleman)

    Any ideas? Many thanks – !

    Thread Starter soleman

    (@soleman)

    Is this the correct forum?

    Thread Starter soleman

    (@soleman)

    Nobody?

    Thread Starter soleman

    (@soleman)

    I figured it out. Took mad long…..

    I’m not sure how you ended up doing this, but maybe something like this might work:

    $my_sidebar = get_post_custom_values("sidebar");
    get_sidebar($my_sidebar);

    This would be where your sidebars are named sidebar-1.php, sidebar-2.php, and so on.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘get_sidebar How Can I Make It Dynamic for is_single and is_category??’ is closed to new replies.