WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Exempting "About Me" page from page template (5 posts)

  1. Janetis
    Member
    Posted 1 year ago #

    I've set up my site so that the blog updates on a page instead of home. However, there is a page that I would like to exempt from the blog format: my "About Me" page. I'm not sure of the easiest way to go about this.

    Voilà the site: http://www.wearsanegyptianring.com

    Notice: when you click the link that says, "Blog," you get my blog, but if you click "Janet," same thing unfortunately!

  2. jrstudio
    Member
    Posted 1 year ago #

    Hi,

    you will need to be more specific about this.

    can you tell me how did you do so the posts are displaying on "Blog" page instead of "Home"? Did you make a new template php file, or did you just switched options in Admin > Settings > Reading?

    PS. I had to google to find out what "exempt" means.

  3. Janetis
    Member
    Posted 1 year ago #

    I altered the original page.php thus-ly:

    <?php get_header(); ?>
    
    	<div class="single_content">
    
            <?php
            $args = array(
                         'category_name' => 'blog',
                         'post_type' => 'post',
                         'posts_per_page' => 4,
                         'paged' => ( get_query_var('paged') ? get_query_var('paged') : 1),
                         );
            query_posts($args);
            while (have_posts()) : the_post(); ?>            
    
            <div class="blog_box">
    
    	<h3><a href="<?php the_permalink(); ?>" class="img_hover_trans"><?php the_title(); ?></a></h3>
    		   <a href="<?php the_permalink(); ?>" class="img_hover_trans"><?php the_post_thumbnail('featured-blog-listing'); ?></a>
            <p><?php $temp_arr_content = explode(" ",substr(strip_tags(get_the_content()),0,430)); $temp_arr_content[count($temp_arr_content)-1] = ""; $display_arr_content = implode(" ",$temp_arr_content); echo $display_arr_content; ?><?php if(strlen(strip_tags(get_the_content())) > 430) echo "[.....]"; ?></p>
            </div>
    
    		<!--//blog_box-->
    
            <?php endwhile; ?>
    
            <div class="navigation">
              <div class="left"><?php previous_posts_link('« Previous') ?></div>
              <div class="right"><?php next_posts_link('Next »') ?></div>
              <div class="clear"></div>
            </div><!--//nagivation-->
            <?php wp_reset_query(); ?>                  
    
          </div><!--//single_left-->
            <?php get_sidebar(); ?>
    
          <div class="clear"></div>
    
        </div><!--//single_container-->
    
    <?php get_footer(); ?>

    Would I need to create another page template for the "About Me?" I'm trying the avoid that, since its not entirely clear to me how one adds a new template to an already-uploaded theme on WordPress without taking everything down, adding needed page, then uploading everything again. If possible, I'd like to write something in page.php that recognizes "Janet" must be formatted alternatively.

  4. jrstudio
    Member
    Posted 1 year ago #

    Unfortunately what you did, you altered "page.php" file which is used for every new page you make through admin panel. You need to understand that in first place. Page.php is template used for every new Page you make in admin panel, single.php is template used for displaying a single post, index.php of course for front page.
    So the best way is to design your page.php in a way that is okay for every new page you create in Admin panel (ex. About me). It should be similar to index.php. The best way is just to copy everything from index.php and just alter it to suits your needs. Then you can easily write whatever you want, and it will be shown.

    Currently it cant do that, cause you altered it to just show posts, and now every new page you make will be the same, just posts.

    What you need to do is actually easy. You just need to make a new PHP file inside of your theme folder, ex. blog.php, and whats important is this line of code

    <?php
    
    /*
    Template Name: Blog
    */
    
    ?>

    Rest of that file can be the same as your altered page.php which means you can just copy paste it. Then go to Admin panel, Add new page called Blog (or do it for the one you already have). You should now see your custom template name appear under the “Template” pull-down in the Page Edit screen, as indicated in the pic below by the green arrow.
    picture

    When you have your blog.php up and working correctly, you should redesign page.php (note that once you have blog.php, you can clear your query_posts code from page.php)

  5. Janetis
    Member
    Posted 1 year ago #

    Thank you thank you! Works perfectly.

Topic Closed

This topic has been closed to new replies.

About this Topic