PHP segítség WordPresshez: featured categories szétválasztása külön ablakokba
Akinek lenne rám egy 10-15 perce (Aki jól ért a PHP-hoz lehet annyi lenne neki) annak megköszönném, ha megnézne 1 kódot.
A lényeg:
wpzoom pont com/images/doc/cadabrapress/guide.jpg
Van egy téma (linket nem tudok beírni), és látható, hogy a featured categories nincs szétbontva, hanem ilyen fülekkel lehet lapozni. Szerintem egy hírportál-féle oldal esetében ez nem túl előnyös, hogy a látogató nem látja az összes kategória legfrissebb híreit, ezért szét kéne választani, hogy egymás alatt legyenek ezek az ablakok, mint a legtöbb WP theme esetében. Próbálkoztam, de nem jártam sikerrel, túl sok a változó, és nekem kezdőnek nem elég átlátható a dolog :) De szerintem aki ért hozzá, az jól átlátja...
Talán azt kéne, hogy a kategóriákat máshogy kiolvasni, és mindet külön divbe tenni. Aztán azokba belepakolni a poszt adatainak változóit.
Itt íratja ki oda fülekbe a kategóriákat:
PHP kód:
<?php if ($wpzoom_tab_cat_show == 'Yes') { ?>
<div class="tabbed">
<div class="rounded">
<ul class="tabs">
<?php
$i = 0;
$c = 10;
while ($i < $c)
{
$i++;
$category = "wpzoom_tab_cat_" . "$i";
if ($$category != 0)
{
$cat = get_category($$category,false);
echo'<li><a href="#tab'.$i.'">'.$cat->name.'</a></li>';
}
}
?>
</ul>
És ezután pedig ezek alapján íratja ki a posztokat:
PHP kód:
<div class="tab_container">
<?php
$cc = 0; $c = 10;
while ($cc < $c)
{
$cc++;
$category = "wpzoom_tab_cat_" . "$cc";
if ($$category != 0)
{
$cat = get_category($$category,false);
$catlink = get_category_link($$category);
$breaking_cat = "cat=".$$category; // Breaking tag slug
wp_reset_query();
query_posts("showposts=$wpzoom_tab_cat_posts&$breaking_cat&order_by=post_date&order=DESC");
?>
<div id="tab<?php echo $cc; ?>" class="tab_content">
<?php if ( have_posts() ) : ?>
<ul>
<?php
$x = 0;
while (have_posts()) : the_post(); update_post_caches($posts);
$x++;
?>
<li<?php if ($x % 2) { } else { echo ' class="right_col"';} ?>>
<?php unset($img);
if ( current_theme_supports( 'post-thumbnails' ) && has_post_thumbnail() ) {
$thumbURL = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), '' );
$img = $thumbURL[0]; }
else {
unset($img);
if ($wpzoom_cf_use == 'Yes') { $img = get_post_meta($post->ID, $wpzoom_cf_photo, true); }
else {
if (!$img) { $img = catch_that_image($post->ID); } }
}
if ($img) { $img = wpzoom_wpmu($img); ?>
<a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>"><img src="<?php bloginfo('template_directory'); ?>/scripts/timthumb.php?src=<?php echo $img ?>&w=75&h=75&zc=1" alt="<?php the_title(); ?>" /></a><?php } ?>
<a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a><span class="comm_bubble"><?php comments_popup_link('0', '1', '%', ' ', ' '); ?></span>
<span class="meta"><?php the_time("$dateformat $timeformat"); ?> <?php edit_post_link( __('Edit', 'wpzoom'), ' ', ''); ?></span>
<?php wpe_excerpt('excerpt_tabs', 'wpe_excerptmore'); ?>
</li><?php endwhile; ?>
</ul><?php endif; ?>
</div>
Köszönöm!
re: PHP segítség WordPresshez: featured categories szétválasztása külön ablakokba
Szia, ha jól látom, akkor az első és a második blokkban is körbejárja ezeket a kategóriákat, tehát ha neked a tab-os lapozás nem kell, akkor azt ki lehet iktatni. Betettem egy h2 tag közé a kategória nevét, illetve hozzáadtam egy div-et, így elvileg mennie kell, ha nem megy keress meg privátban és megpróbálok segíteni.
PHP kód:
<div class="tab_container">
<?php
$cc = 0; $c = 10;
while ($cc < $c)
{
$cc++;
$category = "wpzoom_tab_cat_" . "$cc";
if ($$category != 0)
{
$cat = get_category($$category,false);
$catlink = get_category_link($$category);
$breaking_cat = "cat=".$$category; // Breaking tag slug
wp_reset_query();
query_posts("showposts=$wpzoom_tab_cat_posts&$breaking_cat&order_by=post_date&order=DESC");
?>
<div id="tab<?php echo $cc; ?>" class="tab_content">
<?php if ( have_posts() ) : ?>
<h2><?php echo $cat->name; ?> kategória tartalma</h2>
<div class='featured_category'>
<ul>
<?php
$x = 0;
while (have_posts()) : the_post(); update_post_caches($posts);
$x++;
?>
<li<?php if ($x % 2) { } else { echo ' class="right_col"';} ?>>
<?php unset($img);
if ( current_theme_supports( 'post-thumbnails' ) && has_post_thumbnail() ) {
$thumbURL = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), '' );
$img = $thumbURL[0]; }
else {
unset($img);
if ($wpzoom_cf_use == 'Yes') { $img = get_post_meta($post->ID, $wpzoom_cf_photo, true); }
else {
if (!$img) { $img = catch_that_image($post->ID); } }
}
if ($img) { $img = wpzoom_wpmu($img); ?>
<a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>"><img src="<?php bloginfo('template_directory'); ?>/scripts/timthumb.php?src=<?php echo $img ?>&w=75&h=75&zc=1" alt="<?php the_title(); ?>" /></a><?php } ?>
<a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a><span class="comm_bubble"><?php comments_popup_link('0', '1', '%', ' ', ' '); ?></span>
<span class="meta"><?php the_time("$dateformat $timeformat"); ?> <?php edit_post_link( __('Edit', 'wpzoom'), ' ', ''); ?></span>
<?php wpe_excerpt('excerpt_tabs', 'wpe_excerptmore'); ?>
</li><?php endwhile; ?>
</ul>
</div><?php endif; ?>
</div>