WordPress.org

Ready to get started?Download WordPress

Forums

How to get post/page name? (5 posts)

  1. deko
    Member
    Posted 3 years ago #

    the last line in my footer.php is a call to an external script:

    <?php @ include '/home/user/public_html/cgi-bin/myscript.php'; ?>

    so myscript.php runs with each page view.

    What I want to do is pass the current post name or page name with the script. Something like this:

    <?php
    $viewed = get(post_name);
    @ include '/home/user/public_html/cgi-bin/myscript.php?id=$viewed';
    ?>

    The goal is to log all page views so I know which is most popular.
    Is this possible? Any suggestions?

  2. MichaelH
    Member
    Posted 3 years ago #

    Wouldn't $post->post_title contain what you want?

  3. deko
    Member
    Posted 3 years ago #

    Thanks MichaelH. I'll give it a toss and let you know.

    I've looked at a number of wp plug-ins but all I really want are the top 5 pages, sorted by page views, and the ability to insert these stats wherever I want on my blog.

  4. deko
    Member
    Posted 3 years ago #

    While $post->post_title certainly does return the post title, the problem is passing it to my script.

    This code doesn't work:

    <?php
    $viewed = $post->post_title;
    @ include '/home/user/public_html/cgi-bin/myscript.php?id=$viewed';
    ?>

    It would work if I called it like this:

    $viewed = $post->post_title;
    @ include 'http://www.myblog.org/myscript.php?id=$viewed';
    ?>

    but I don't want my myscript.php publicly accessible.

    There must be an easy way to log post_title on each page view...

  5. MichaelH
    Member
    Posted 3 years ago #

    Might want to look at some of the popular post plugins to get an idea of how they do it...

    http://wordpress.org/extend/plugins/tags/popular

Topic Closed

This topic has been closed to new replies.

About this Topic