WordPress.org

Ready to get started?Download WordPress

Forums

Best Way to use PHP code with WordPress Pages? (6 posts)

  1. bakert
    Member
    Posted 8 years ago #

    I am wondering what the "best practice" solution to the following problem is. Any advise you can give would be gratefully received.

    I have a page that describes a program I am writing. Every time I release a new version of the program it is copied up to my webserver automatically. The page that describes the program dynamically determines the size of the file and displays it like so: "Boggle_0_3.zip (2.3MB)". The "2.3MB" bit is determined by a bit of PHP every time the page is requested.

    Now I have switched to WordPress I'd like the page describing the program and offering it for download to be a WordPress "page" to get the look and feel the same as everything else, etc. Except there's no (simple) way for it to do the dynamic lookup of how large the files are even though it is a simple bit of PHP.

    So I suppose my question is: 1. Can I somehow put PHP code into a WordPress page? And if not, 2. How do I hook into my WordPress look and feel from a PHP of my own creation?

    Thanks for looking, Tom

  2. chaaban
    Member
    Posted 8 years ago #

  3. bakert
    Member
    Posted 8 years ago #

    These look great - I should have thought to look for a plugin but I was hung up on thinking there would be an official way. Thanks very much.

  4. Michael Bishop

    Posted 8 years ago #

    bakert, also know that you can create a custom Page template,with your code in it, and then when you go to Write ->Page, simply choose that template.
    /Pages#Page_Templates

  5. Beel
    Member
    Posted 8 years ago #

    That last suggestion is the best idea. The others are better for posts, not pages. Pages are a "one time" deal so I just create a template with all the php code I want in it and don't have to worry if the plugin is activated or not.

  6. bakert
    Member
    Posted 8 years ago #

    Ah yes! Of course. I should have realised that. I wasn't thinking that I could put all the content into the template and then just create an empty page. That's definitely the best answer for me.

    Thanks all! Very impressed with the speed of feedback in this community/forum.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags