• Using the new Manage > Pages to create pages stored in the DB, how does one use PHP/CSS to format these pages?

    Can’t seem to find anything in the Codex…

Viewing 10 replies - 1 through 10 (of 10 total)
  • Hmm, well, they use the same stylesheet as the rest, and the same css descriptors/tags. Try creating a new page through the admin page, and you’ll see that pages are no more than glorified single-entries.

    2fargon is right. Pages aren’t actually static; I believe the official description is that they “live outside of the normal blog chronology”.

    That said, 2fargon is wrong; pages don’t have to use the same css etc. You can make any page look/act differently.

    In the /wp-content/themes/whatever theme you"re using/ directory, if you create a new file (say, snarfer.php) with the following at the top of the file:

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

    you can then use the Write Page tab in your site’s admin section to create a new page and select Snarfer from the Template drop down box in the Write Page tab.

    In your new snarfer.php you can put it whatever markup/php/css you want.

    indeed, but when you use snarfer, nothing will show up on your page. whats the code to actually get the content on the page…

    The code I gave above is only the beginning. All it does is tell wordpress the name of the template. To make the template useful, you need to put in code that ‘actually [gets] the content on the page’, as you say.

    I would suggest, as a start, copying single.php or some other file from one of your pre-existing themes over to your new template snarfer.php and then adding that code I mentioned at the top of that new file. From there, you won’t have to create, but only modify ??

    EDIT:

    It’s all about HTML and WordPress’ template tags.

    Thread Starter rusyn

    (@rusyn)

    I will give it a go…

    Rusyn said "Can't seem to find anything in the Codex..."

    This is true for the time being because 1.5 is still BETA and already we have seen some major changes in the template system. There isn’t much use in spending a lot of time documenting something until it’s much more stable. You can always check out rboren’s site for information which he has posted on this subject.

    related… i try adding php to pages via this system, and it just removes the php tags and spits out the code… I’m trying to move my “MyStuff” plugin page to a “wp”-managed page (i don’t know how to refer to it without it getting confusing ?? ). So… I throw the following in:

    <?php
    $my_stuff = new my_stuff();
    $my_stuff->set_link_referrer('www.amazon.com','gregorybowers-20');
    $my_stuff->set_list_type('ul');
    $my_stuff->set_title_element('h3 class="headline"');
    $my_stuff->add_stuff('books', 'Currently Reading:', false, 5);
    $my_stuff->add_stuff('books', 'Completed:', true, 5);
    $my_stuff->display(); ?>

    and it just shows up like that…

    You could always use the Run PHP plugin to get PHP to work in the pages.

    Depending on where you want the PHP, a custom Template would be more efficient. See https://codex.www.ads-software.com/Pages

    the template method seemed to kind of go against the whole reason I was moving this to the “Pages” system… easy editing and maintenance. That and the methodology seemed a bit odd… anyway, the RunPHP plugin worked perfectly. Thanks.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘1.5 Static Pages and PHP?’ is closed to new replies.