soleman
Member
Posted 4 years ago #
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'); }
?>
soleman
Member
Posted 4 years ago #
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.....
soleman
Member
Posted 4 years ago #
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....!
soleman
Member
Posted 4 years ago #
I can't think of any other angle to go at this. Just tough with my limited coding skills... like mad limited - !
soleman
Member
Posted 4 years ago #
Any ideas? Many thanks - !
soleman
Member
Posted 4 years ago #
Is this the correct forum?
soleman
Member
Posted 4 years ago #
soleman
Member
Posted 4 years ago #
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.