WordPress.org

Ready to get started?Download WordPress

Forums

How to include new PHP page? (4 posts)

  1. brettr
    Member
    Posted 6 years ago #

    I'd like to add a download.php page to my blog. It will be used to track various downloads (MP3, EXE, etc) via javascript in the page. I have the page up but it is basically a blank page with the download link. It works fine now and tracks downloads but I want the blog shell wrapped around this page so it looks like part of the blog. I tried to include some of the code from category.php but got reference errors because download.php couldn't find the functions I copied over from category.php.

    When I reference download.php, it is a direct reference such as mysite.com/download.php?file=some.mp3. Should I reference it a different way to get the blog shell to display?

  2. GOBLUE14
    Member
    Posted 6 years ago #

    This is totally off the top of my head, but you may want to put it in the theme folder with the header.php, category.php, etc. so everything is on the same directory level.

  3. brettr
    Member
    Posted 6 years ago #

    What would that reference look like? I tried:
    mysite.com/wp-content/themes/default/download.php?file=some.mp3

    and that just displays the same blank page. Then I added in the code I had used from category.php. That gives an error because get_header() isn't recognized. I'm guessing the file needs to be referenced a certain way.

  4. GOBLUE14
    Member
    Posted 6 years ago #

    I'm not sure that I totally follow you with the download stuff, but as far as "wrapping the blog shell around it", you can just take the "Main Index Template" code (or "index.php", or whatever it may be called in a particular theme), copy it, save it as "download.php" and then put your javascript, etc. in the "main" div, keeping the PHP that wordpress uses to get the header, footer, sidebar, etc. Kinda like this:

    <?php get_header(); ?>
    <div id="main">
        PUT YOUR JAVASCRIPT AND SUCH HERE
    </div>
    
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    Beyond that, maybe someone else can help with the references and such for the download tracking.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.