WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] Manual link to new php file outside of loop?

[Resolved] Manual link to new php file outside of loop?

  • Perhaps I am stuck in HTML land, but I cannot seem to figure out why WP ignores my links.

    I created a new registration form and put the necessary code into a file named ‘register.php’ which is located in the /wp-content/themes/my_theme directory. My header includes a small form which changes between showing the abbreviated user info when logged in and a small login form when not logged in. This works successfully and is called via <?php include('/login.php'); ?>

    At the bottom of this form are two links allowing a user to either register as a new member or receive a password hint/reset. Since these are actual links, I currently have the code set as:
    <p><a href="<?php network_home_url(); ?>/register.php">Register</a> or <a href="<?php network_home_url(); ?>/reset.php">reset your password</a></p>

    However, upon clicking either of the links, rather than navigating to the register.php or pass_hint.php files, the server loads the index.php file. I am sure that I am missing some fundamental (and simple) way that WP navigates and looks for files.

    Can anyone help with this?

Viewing 6 replies - 1 through 6 (of 6 total)
  • I assume this has something to do with The Loop function. It surprises me that nobody has encountered this issue before…

    Hi, can you share a link to your site so we can see exactly where youre links point? you might need to use get_stylesheet_directory() instead of network_home_url(); (not sure of this-are you using multi-site?)…
    Regards

    I’m currently involved in development on a localhost so there are no public pages available at this point.

    My solution at this point has been to simply create a page from the admin screen with the desired content within, but this limits my ability to add code when applicable.

    The problem is not with the network_home_url() (and yes, this is multisite), but with the inability to have the index.php direct to the href link. For example, when I attempt to link to a separate file: <a href="<?php network_home_url(); ?>/register.php">Register</a> I get a 404 error. I am able to bring up this file using an include() call, but this is supposed to be a link, not an include.

    Am I even making sense?

    I suppose I’m trying to figure out a way to have either of the following code effects occur upon clicking the “Register” link:

    get_template_part('register');
    include('/register.php');

    CGAdmin, I think you need to review this page in order to sort things out. In wordpress there are 2 ways to link to pages: to have the pages created throw Dashboard->pages->add new and setting a custom template to that page or to use specific wordpress links for different tasks for example “wp-login.php”… reading the above article will give you more info,
    Regards

    Ohh… It didn’t even dawn on me that I could create a template.

    All I did was add the template identification code to the top of my previously existing my_file.php and simply pointed the appropriate blank page in the Admin section to this proper template.

    A little silly if you ask me, but it works.

    Thanks!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘[Resolved] Manual link to new php file outside of loop?’ is closed to new replies.
Skip to toolbar