WordPress.org

Ready to get started?Download WordPress

Forums

1.5 - Working with "Pages" (7 posts)

  1. piper
    Member
    Posted 9 years ago #

    i am migrating all my websites to WP and i need to understand how to control "pages".

    i just made my first page and its still located under my default "news" category even though i have created a new category that i would like it to go under instead.

    i would also like to tweak the way that WP handles my "pages" so that i can make them fall into the exact same URL that they are originally on, so that i don't lose any links that are pointed to those pages on my static site.

    can anyone help me figure this out? thanks in advance!

  2. Michael Adams (mdawaffe)
    Member
    Posted 9 years ago #

    Pages can't belong to categories (well... it might be most rigorous to say they can only be in the default category, but that's getting into how you define things).

    Most people (I think) will end up removing the the_category tag from their page template. If you're looking to associate static content with particular categories, see http://wordpress.org/support/topic.php?id=22567#post-128275

    But back to Pages. You should check out: http://codex.wordpress.org/Pages

    The Page permalink is defined by it's hierarchy (see the SubPages part of the above link) and it's Page Slug (which you can manually edit in Write->Write Page).

  3. pieceoplastic
    Member
    Posted 9 years ago #

    i have similar questions as piper does.
    on my existing website (with a WP 1.2.2 blog) i have a few static pages that call some wp functions.

    its fantastic that wp now allows me to turn these static pages into Pages, making it much easier to update things, occasionally, and making it much less of a hassle to apply my template changes website-wide.

    now here are my 2 questions:

    1. i would like to keep the existing page and link architecture of my site, because i have used some of the links quite often. for instance: one of the static pages is called mixes.php and contains info about my dj-mixes. the link http://mysite/mixes.php is now printed on all the cds i have sold and sent out.
    if i now start to use a Page for the content, in the regular way, that link would switch.

    i know could solve this issue via .htaccess, of course. but maybe there is another way.

    as i understand wp is quite flexible. so here's the question: is there a way to keep a file called mixes.php in my root folder, exactly where it was sitting before, and to call the content of one dynamic WP Page via php include?
    i know this works for the template functions. but what tag would i have to use to include just the the_content (and maybe a few other Template tags) into my mixes.php.

    2. the second question is about the template functions.
    these Pages would use most of the same template components, same sidebar, same footer, same index, but they would need a different header.
    how modular is that?
    can i create a header2 for instance and call that from say my mixes.php via php include?

  4. Michael Adams (mdawaffe)
    Member
    Posted 9 years ago #

    1. I think it would work (but have not tried it). You'd need to make sure wp-blog-header.php and whatnot gets called. I believe there's been some forum posts recently about similar goals.

    For your specific case, though, .htaccess might be best.

    To get the data, you'll need The Loop. This is because you wouldn't be using a PHP include since information about Pages is stored in the database, right along side Posts. For example, the_content can only be used inside The Loop.

    2. I suppose by "these Pages" you mean "these Pages of mine". Trusting that you're claim is true :) , yes I believe you could create a header2.php. Check out Theme Development and what it says about TEMPLATEPATH. Then look at how the default theme of 1.5 (a modified Kubrick) uses it to see what it means.

    Actually, if you're mixes.php is in your base directory, TEMPLATEPATH includes might be a bit different. I've no idea. I'm sure it can be made to work (if it doesn't work right off the bat).

  5. pieceoplastic
    Member
    Posted 9 years ago #

    dude, thanx for your quick response!
    1. i just realised that the_content would be not the right tag in my case, because i would need to be able to specify, only display Page such and such by using a php include tag. now whether or not such a tag exists and would even work in this particular case, would be my next question.
    can i call just certain specified, by their ID, contents using template tags inside the loop, or does that not work at all?

    the main reason i am asking is that my hosts are being gay and have blocked .htaccess and only allow for very limited .htaccess via their admin interface. so i am not even sure i could do it via .htaccess on my current host. i knowww...
    the other reason is aesthetics, i am quite fond of the simplicity of just having http://mysite/mixes.php as the url.

    2. and for this question, yes it does seem to work. what i think i have to do is use php include and use the path to the theme like so:
    php include("wp-content/themes/"MyTheme"/header2.php");
    and in header2.php specify the template name like so:
    php
    /*
    Template Name: header2
    */

    i have been able to get this to work with my narchives2.php

  6. Michael Adams (mdawaffe)
    Member
    Posted 9 years ago #

    1) I think the Loop and the_content is still what you want, unless you want to get into custom SQL queries with the $wpdb object. Again, I don't know exactly how things work outside of the "normal" WordPress templates (your mixes.php being essentially a template you're putting in a funny directory), but you should be able to call from mixes.php something like:
    query_posts('pagename=mixpage');

    Where you've written a page called "mixpage" and given it content etc. Then run the Loop as 'normal' from mixes.php calling the_content and all the rest.

    Something like that should work, anyway.

    BUT... since you like "http://yoursite/mixes.php" so much, wouldn't you like "http://yoursite/mixes/" even better? That's the permalink a Page with name "Mixes" (or with a Page Slug manually set to "mixes") would get without any of this other file nonsense :)

    Then you could just make a custom template in your theme directory as you describe above, and not worry about keeping mixes.php in the base dir. "But that gets into my server and their .htaccess restrictions again", you say. Well - I don't know what to do about that. You might check out Ryan Boren's alternate Rewrite Rules which do all the permalinking internally in WordPress and greatly simplify your .htaccess (and eliminates the need to continually write to it). I've used it for a while on a test site, and have had no problems with it. The only downside: 404's aren't logged to an error log (but the right headers are sent to the client). You could fix this with some kind of logging plugin, though.

    2) I'm a little surprised you can't do
    <?php include (TEMPLATEPATH . "/header2.php"); ?>
    but maybe there's some hoops you have to go through first before that works. As I said, I'm ignorant about putting files in funny places :)

  7. Michael Adams (mdawaffe)
    Member
    Posted 9 years ago #

    @piper
    In addition to what I said about a Page's permalink above, all this talk about .htaccess reminds me:

    If you can't get the Pages' permalinks to line up right with your old links, you could manually add some Rewrite rules in .htaccess to take care of it. Just make sure you put them outside of the

    # BEGIN WordPress
    ...
    # END WordPress

    stuff.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.