Wordpress Themes - WP Forum at BFA

Wordpress Themes - WP Forum at BFA (http://forum.bytesforall.com/index.php)
-   Montezuma Theme (http://forum.bytesforall.com/forumdisplay.php?f=53)
-   -   Creating Featured posts - endwhile not working? (http://forum.bytesforall.com/showthread.php?t=20072)

munchy_cool Apr 6, 2013 06:22 PM

Creating Featured posts - endwhile not working?
 
I am adding the below code to my index.php to retrive 3 posts from the Featured category but it does'nt seem to work and gets only 1 post and displays endwhile below it, can anyone help?

<div id=”featured”>
<?php
query_posts(‘posts_per_page=3&cat=301′);
if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
<h2><a href=”<?php the_permalink(); ?>”><?php the_title(); ?></a></h2>

<?php endwhile;?>

<?php wp_reset_query(); ?>
</div>

juggledad Apr 7, 2013 03:26 AM

If you are doing that in the virtual template it won't work because you are using php that is not allowed in the 'limited php code'.

munchy_cool Apr 7, 2013 06:14 AM

then how do i do it, where do i put the code? any other way you can suggest?

juggledad Apr 7, 2013 07:52 AM

Try making a copy of the index.php virtual templete and call it category-yourcatname.php and see if that will work

munchy_cool Apr 8, 2013 05:17 PM

so i added a new main template by copying index.php (named it category-news-2) that was the slug on my Featured category but I see no change in the main page, am I missing something.

below is the code in the new main template.

Code:

<!--<div id="container">-->

<?php get_header(); ?>


<div id=”featured”>
<?php
query_posts(‘posts_per_page=3&cat=301′);
if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
<h2><a href=”<?php the_permalink(); ?>”><?php the_title(); ?></a></h2>

<?php endwhile;?>

<?php wp_reset_query(); ?>
</div>

<div id="main" class="row">


        <div id="content" class="cf col8">
               
                <?php bfa_content_nav( 'multinav1' ); ?>
               
                <?php bfa_loop( 'postformat' ); ?>
               
                <?php bfa_content_nav( 'multinav2' ); ?>
               
        </div>
       
        <div id="widgetarea-one" class="col4">
                <?php dynamic_sidebar( 'Widget Area ONE' ); ?>
        </div>

</div>
       
<?php get_footer(); ?>

<!--</div>-->


juggledad Apr 8, 2013 07:01 PM

there is no current way, using the theme options, to limit the number of posts returned other than the 'dashboard->settings->reading->Blog pages show at most setting'

if you want to format the look/feel of a particular category:
1) toss your 'query_post' code in the trash
2) if your category is 'news' then the virtual template should be 'category-news'
3) create a copy of the subtemplate 'postformat.php and you can make changes there - remember you can only use HTML and the Limited PHP Code that is available.


All times are GMT -6. The time now is 03:30 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.