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 a page of posts/PHP not working in custom main template? (http://forum.bytesforall.com/showthread.php?t=20548)

agent314 Jun 24, 2013 04:29 PM

Creating a page of posts/PHP not working in custom main template?
 
I have recently installed the Montezuma theme and love the look and feel of it.

I am trying to create a page template that will list posts of a given category/multiple categories in alpha order by post title, but every time I create a custom template and assign it to my page, it seems to incorrectly parse out

What I have in my theme:

Code:

<?php get_header(); ?>

<div id="main" class="row">
       
        <div id="content" class="col8">
               
                <div id="post-<?php the_ID(); ?>" <?php post_class('cf'); ?>>

                        <h1>
                                <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" rel="bookmark"><?php the_title(); ?></a>
                                <?php bfa_comments_number(); ?>
                        </h1>
                       
                        <div class="post-bodycopy cf">
                                <?php the_content(); ?>
<?php
// The Query
query_posts( array(
  'category_name' => 'food-drink',
  'posts_per_page' => -1 ) );
?>

    <?php
// The Loop
while ( have_posts() ) : the_post();
        echo '<h1>';
        the_title();
        echo '</h1>';
        the_excerpt();
        the_date();
        echo 'Categories: ';
        the_category(', ');
        echo '</p>';
        endwhile; ?>

          <?php

          // Reset Query
          wp_reset_query();

          ?>
            <?php wp_link_pages( array(
                                        'before' => __( '<p class="post-pagination">Pages:', 'montezuma' ),
                                        'after' => '</p>'
                                ) ); ?> 
             
           
                        </div>

                        <?php edit_post_link( __( 'Edit', 'montezuma' ) ); ?>

                </div>
               
                <?php comments_template( '', true ); ?>
               
        </div>
       
        <div id="widgetarea-one" class="col4">
                <?php dynamic_sidebar( 'Widget Area ONE' ); ?>
        </div>
               
</div>

<?php get_footer(); ?>

And this is what appears, formatted with the style of the main body text of my page:


Code:

Content goes here.

'food-drink', 'posts_per_page' => -1 ) ); ?> '; the_title(); echo ''; the_excerpt(); the_date(); echo 'Categories: '; the_category(', '); echo '
'; endwhile; ?>

I've run the PHP through a parser and removed all errors it reported, but it still doesn't seem to work as expected.

Am I doing something wrong? Is the Montezuma theme stripping out certain PHP code and rendering the loop inert? Do I need to change a setting or adjust the code somewhere?

I am a complete newbie to PHP so it could be something very obvious and I just don't have sophisticated enough understanding to recognize it, but if someone can point out my error and/or direct me to where I can learn more, that would be immensely helpful :)

juggledad Jun 24, 2013 06:45 PM

Is this a physical or virtual template?

agent314 Jun 24, 2013 06:57 PM

I believe it is a virtual template - I created it using the Main Templates option within the Montezuma theme backend.

juggledad Jun 24, 2013 07:34 PM

if you read the onscreen documentation you wll notict that there is limitd PHP you can put in a template. There is even a tab in the upper right that will list all the php you can use.

agent314 Jun 24, 2013 10:21 PM

Okay, thank you for clearing that up - I read that there was limited PHP allowed and scoped out the list of functions, but I didn't realize it was limited to ONLY those functions and their args.

I assume that is only for the virtual templates? i.e. if I bring it in as a physical template, I can still use the various bits of code I've found in the Codex to accomplish what I've been trying?

jerryc Jun 25, 2013 12:29 AM

This post might help. A sidebar can go in the content section of a template, and you can use any php in the sidebar with this technique. You may need to adjust the CSS so nobody notices that you've used a sidebar. Juggledad also found a different plugin that works right in the text widget.

agent314 Jun 25, 2013 12:38 AM

Excellent - I will take a look at those tomorrow. Thanks juggledad+Jerry


All times are GMT -6. The time now is 05:55 PM.

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