ivanasetiawan
Member
Posted 1 year ago #
Here is the site I am working on: http://stubbydog.org/live/
My question is: how do I give an option to hide "minor headlines"?
(minor headlines is the one located under featured content gallery - without thumbnail)
Because whenever I put "0(zero)" under "Number of posts to show:" - it always falls back to 3 posts (seems like it already set up by default).
Can anybody help me please?? Here is the code:
<div class="minorheadlines">
<?php $recent = new WP_Query("cat=".get_theme_mod
('featured_top_right')."&showposts=".get_theme_mod('featured_top_right_num'));
while($recent->have_posts()) : $recent->the_post();?>
<div class="minor">
<!--This is the tittle-->
<strong>
<a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a>
</strong>
<!--This is the content-->
<?php the_content_limit(250, __("Read more")); ?>
</div> <!--minor ended-->
<?php endwhile; ?>
<?php if(get_theme_mod('featured_top_right')) : ?>
<?php endif; ?>
It looks like the if test for 'featured_top_right' needs to be moved to just after the starting div, like this:
<div class="minorheadlines">
<?php if (get_theme_mod('featured_top_right')) : ?>
<?php $recent = new WP_Query("cat=".get_theme_mod
('featured_top_right')."&showposts=".get_theme_mod('featured_top_right_num'));
while($recent->have_posts()) : $recent->the_post();?>
<div class="minor">
<!--This is the tittle-->
<strong>
<a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a>
</strong>
<!--This is the content-->
<?php the_content_limit(250, __("Read more")); ?>
</div> <!--minor ended-->
<?php endwhile; ?>
<?php endif; ?>
ivanasetiawan
Member
Posted 1 year ago #
Hi vtxyzzy,
Thanks for helping :)
I moved the <?php if (get_theme_mod('featured_top_right')) : ?> just after the starting div but when I put 0(zero) under "Number of posts to show:" on the admin (Theme Options) ==> on the homepage, there are 3 posts show instead of 1.
Weird enough when I put 1, it shows 0ne post as well as when I put 2, 3, 4. It adjusts accordingly, but zero seems to be impossible.
Is there any other option; like a checkbox to give an option to hide the section if they want it?
I am guessing that you should be able to control this from the theme options because of the use of the get_theme_mod function. Check to see if there is a theme option to use/not use a featured_top_right section.
ivanasetiawan
Member
Posted 1 year ago #
where can I check it? is it under function.php?
It should be in the Admin panel somewhere. Usually it is under Appearance, with the name 'Theme Options'.
ivanasetiawan
Member
Posted 1 year ago #
Yes, I have been adjusting the amount through Theme Options. That's why it confuses me when 1 => 1post, 2 =>2posts, etc
while 0 => 3posts
I was thinking that there might be a separate option just to not show the section, but I guess not.
When you enter zero, does it stay zero in the Theme Options? If so, you can modify your code slightly to use that:
<div class="minorheadlines">
<?php if (get_theme_mod('featured_top_right') && get_theme_mod('featured_top_right_num')) : ?>
<?php $recent = new WP_Query("cat=".get_theme_mod
('featured_top_right')."&showposts=".get_theme_mod('featured_top_right_num'));
ivanasetiawan
Member
Posted 1 year ago #
WOW! solved! :)
Thanks vtxyzzy!