• Hi, with the WP editor I’ve created a page called ‘template.php’

    I would modify the WP Page “Include Template” so that this page contains the function

    locate_template( array( 'template.php')

    There’s a right way or a plugin to do that?

    thanks

Viewing 9 replies - 1 through 9 (of 9 total)
  • Perhaps you should review custom page templates?

    Thread Starter mm88

    (@mm88)

    @esmi thanks for your link, but when the new template is created, I’m not able to link to it.

    I’m not able to find the right relative path ( http://www.mywpsite.com/?p=X">LINK</a> ), because I can’t see the new page between the PAGES panel of my dashboard.

    So, I can create the new template in WP, but how manage it?

    thanks

    Try reading the page at the link I posted above.

    Thread Starter mm88

    (@mm88)

    Sorry. but I don’t understand. I’ve read:

    Changing the URL (or “Slug”) of Your Pages
    If you have Permalinks enabled, and you have selected the Day and Name option (Click the Settings tab, and then click the Permalinks subtab), then the permalink automatically shows up below your post title when you start typing in the body of your post (not just the title).

    Permalink settings

    However, if you have a different permalink option selected, or if you don’t have permalinks enabled at all, you must do the following to edit your page URL:

    Write a page by going to Pages > Add New.
    Click the Publish button to publish your page.
    Go to Pages > Edit.
    Click Edit under the name of your page.
    See the permalink under the title, and click the Edit link to change it.

    But I haven’t an example.

    How modify the link of the page to use it with the site menu?

    thanks

    Phil

    (@owendevelopment)

    1. You don’t create page templates by creating a page and calling it template.php – you need to create a PHP file called template.php and upload it to the theme folder of your theme.

    2. You then create a page in WP admin, and choose the template from the drop-down menu of available templates on the right.

    3. You then add the new page to your menu’s etc like a normal page.

    If you read the link Esmi mentioned, you will learn how to correctly set up a custom template. Searching on Google also helps as there are lots of examples and tutorials. It’s always better to learn these things instead of people doing them for you – you will learn a lot more doing it this way.

    Thread Starter mm88

    (@mm88)

    Hi Phil, thanks for your reply. I’ve followed all steps but I’ve the same problem.

    I’ll try to explain it better.

    I would create a single page with a routine that read all posts with the category “blog2”

    I’ve created the template called blog_tmpl.php with the code:

    <?php
    /*
    Template Name: Blog
    */
    ?>
    <?php get_header(); ?>
    
    			<?php locate_template( array( 'blog.php'), true, false ) ?>
    
    <?php get_footer(); ?>

    I’ve created a WP page called “Blog2” and chosen the new template from the dropdown menu.

    Created the file blog.php with the routine to read all posts with category “blog2”

    however the system read the content of “Blog2” page and NOT the php routine.

    Where is the error?

    please help me, so I can learn something new.

    many thanks

    Thread Starter mm88

    (@mm88)

    the page blog.php contains the query:

    <?php
    /*
    Template Name: Blog
    */
    ?>
    <?php get_header(); ?>
    
    <?php
    
    // The Query
    query_posts('cat=blog2');
    
    // The Loop
    while ( have_posts() ) : the_post();
    	echo '<li>';
    	the_title();
    	echo '</li>';
    endwhile;
    
    // Reset Query
    wp_reset_query();
    
    ?>

    But the WP shows the content of Page “Blog2” instead of the query’results

    why?

    many thanks

    Phil

    (@owendevelopment)

    I’d personally trying doing it like this:

    <?php query_posts('category_name=blog2&showposts=10'); ?>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
      <li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a>
        <?php the_excerpt() ?>
      </li>
    <?php endwhile; endif; ?>

    Showposts can be set to whatever you like.

    Although not sure how you are displaying the posts in this template…

    Thread Starter mm88

    (@mm88)

    Great Phil, it works!

    many thanks!

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Create a Page that include a template’ is closed to new replies.