WordPress.org

Ready to get started?Download WordPress

Forums

Static Page and Inner page Work Great; break site a little (5 posts)

  1. 4evrblu
    Member
    Posted 7 years ago #

    I decided to make some changes to my site by creating a static page and an inner page link that takes you to the primary blog. It is not that hard to do, but the results were unexpected.

    This is what I did:

    I made a copy of my themes index.php file and renamed it to Blog.php. I then turned it into a template by adding

    <?php
    /*
    Template Name: Blog
    */
    $pagenum = $wp_query->query_vars;
    $pagenum = $pagenum['paged'];
    if (empty($pagenum)) {
    $pagenum = 1;
    }
    query_posts("posts_per_page=10&paged=$pagenum");
    ?>

    at the top of the page and saved it to my themes directory.

    I then logged into my site and created a new page, naming it Blog, using 'blog' as a plug; and from the templates dropdown menu I selected Blog. OK, inner page made.

    Next I created a Home page to serve as my static page.

    I did this by making a copy of page.php in my theme. I then renamed it to home.php and added the following line of code <?php query_posts('pagename=home'); ?> right before the line that starts with <?php if (have_posts())…”

    I then created another new page, named this one "Home" and giving it the plug 'home'; then saved it.

    Finally, I went into my header and located the portion of code that said
    <div id="mainmenu">
    <ul class="level1">
    <li class="<?php echo $highlight; ?>"><a href="<?php echo get_settings('home'); ?>"><?php _e('Home','andreas09'); ?></a></li>

    I removed :
    <li class="<?php echo $highlight; ?>"><a href="<?php echo get_settings('home'); ?>"><?php _e('Home','andreas09'); ?></a></li> so that there would not be duplicate 'Home' buttons in my page menu.

    Then I viewed the page.

    Perfect. Almost.

    Here is where it gets strange. Two things happened:

    First, my <!--more--> links were all broken. They were still there, but not a single one of them was working. The Blog page was displaying the entire posts in all of their verbosity. Odd.

    Next, the page buttons are designed to stay reddish once they have been selected and the site redirected to that current selected page. The notion is to let people know where they are.

    The 'Home" button behaves as expected when you click it. It turns red and stays red upon clicking it.

    The Blog button does not. It stays Silver.

    In other words, Home button assumes 'current' status, and Blog button won't

    Any guess as to why Blog button will not remain red?

    Is more information needed? If so, let me know.

    For the record, my funtions.php page controls the look and feel of the page menu buttons.

  2. moshu
    Member
    Posted 7 years ago #

    Usual mistake when using Pages for something they were not meant to... like to display multiple posts :)
    the "more" tag does NOT work on Pages.

  3. 4evrblu
    Member
    Posted 7 years ago #

    Hmmmm ok. I see. So, since the new structure has the index.php entries showing up on blog.php (a page I made) then the more tags break. Is that what you mean?

    So, my only choice is to go back to the default WP structure.

    Rats

    As an aside, this may even explain why the blog button misbehaves. Am I right? Or is the blog button cause by another issue?

    Anyway, Moshu, awesome reply. Thank you. If I figure a workaround I will let ya know. Can we keep this topic open for the time being?

  4. moshu
    Member
    Posted 7 years ago #

    You can keep it open as long as you wish :)

    [btw, I didn't say there isn't a workaround - it's just how it works out of the box]
    Some solutions found here in the forum:
    http://wordpress.org/support/topic/60060?replies=1
    http://wordpress.org/support/topic/67173?replies=16#post-355496
    http://wordpress.org/support/topic/66202?replies=2#post-351142

  5. 4evrblu
    Member
    Posted 7 years ago #

    This is terrific!

    So, if I may, allow me a few more questions..

    blog.php currently begins like this:

    <?php
    /*
    Template Name: Blog
    */
    $pagenum = $wp_query->query_vars;
    $pagenum = $pagenum['paged'];
    if (empty($pagenum)) {
    $pagenum = 1;
    }
    query_posts("posts_per_page=10&paged=$pagenum");
    ?>
    <?php get_header(); ?>
    <?php get_sidebar(); ?>
    <?php include (TEMPLATEPATH . '/right-sidebar.php'); ?>
    <div id="content">
    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>

    The first part appears to identify the page as a template. Should I alter the code to look like this:

    <?php
    /*
    Template Name: Blog
    */
    $pagenum = $wp_query->query_vars;
    $pagenum = $pagenum['paged'];
    if (empty($pagenum)) {
    $pagenum = 1;
    }
    query_posts("posts_per_page=10&paged=$pagenum");
    ?>
    <?php get_header(); ?>
    <?php get_sidebar(); ?>
    <?php include (TEMPLATEPATH . '/right-sidebar.php'); ?>
    <div id="content">
    <?php global $wp_query; $wp_query->is_page = false; if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>

    Is this what I am looking for?

Topic Closed

This topic has been closed to new replies.

About this Topic