How would you pass a variable from a foreach loop, through a link? I have tabs that display correctly. The jQuery works. But when I call the variable $category down where the content sorts, $category doesn't have a value.
<ul id="tabs">
<li id="tab-content-all" class="active-tab">
<a href="javascript:viewTab('content-all');">ALL</a>
</li>
<?php
$categories= get_categories('child_of=104');
foreach ($categories as $category) {
$option = '<li id="tab-content-';
$option .= $category->cat_name;
$option .= '"><a href="javascript:viewTab(\'content-';
$option .= $category->cat_name;
$option .='\');">';
$option .= $category->cat_name;
$option .= '</a></li>';
echo $option;
}
?>
</ul><!--end of tabs-->
<div id="contents-container">
<div id="content-all">
<ul class="gallery">
<?php
/**Get the posts by a category*/
$portfolio_posts = new WP_Query('category_name=portfolio');
/** Initiate the output*/
$output = '';
/** Loop through the post */
while ($portfolio_posts->have_posts()): $portfolio_posts-> the_post();
/** Add Thumbnail to the anchor if present */
$output .= '<li class="g_image"><a href="' . get_permalink($post->ID) . '">';
$size='medium';
if(has_post_thumbnail($post->ID))
$output .= get_the_post_thumbnail($post->ID,$size);
/** Close the widget*/
$output .= '</a></li>';
endwhile;
echo $output;
?>
</ul> <!--end of gallery-->
</div><!--end of ALL -->
<?php
$output = '';
$output = '<div id="content-'.$category->cat_name.'">';
?>
<ul class="gallery">"
<?php
$category_name = strtolower($category->cat_name);
/**Get the posts by a category*/
$portfolio_posts = new WP_Query('category_name='.$category_name);
/** Initiate the output*/
$output = '';
/** Loop through the post */
while ($portfolio_posts->have_posts()): $portfolio_posts-> the_post();
/** Add Thumbnail to the anchor if present */
$output = $category_name;
$output .= '<li class="g_image"><a href="' . get_permalink($post->ID) . '">';
$size='medium';
if(has_post_thumbnail($post->ID))
$output .= get_the_post_thumbnail($post->ID,$size);
/** Close the widget*/
$output .= '</a></li>';
endwhile;
echo $output;
rewind_posts();
?>
</ul> <!--end of gallery-->
</div><!--end of ALL -->
The jQuery tabbing works. Thanks.