WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Links in pages (6 posts)

  1. preskoo
    Member
    Posted 1 year ago #

    Hello.

    I have been wondering if there's a way to use a custom php page that I have created instead of page_id(). I am not talking about using permalinks.

    What I mean is that, for example, in my index.php file I want to create a link to a custom created php page (i.e. family_gallery.php). Something like this:

    <a href="family_gallery.php">Family</a>">

    But when I do this and I click on this link, it redirects me to the 404 page, and not the family_gallery.php page.

    Right now I am using this as my navigation, but I don't want to use page_id().

    <li<?php if ( is_page(74) ) { echo ' class="activef"'; } ?> id="navigation-01"><a href="<a href="<?php echo get_page_link(74); ?>">Family</a>">Family</a></li>

    Is there a way to do this?

    [Bump deleted - please don't do that here]

  2. wpfan1000
    Member
    Posted 1 year ago #

    You need to specify the full path to the file in 'Family"'

    The function get_page_link(74) does that automatically.

    If you put your php file in your current theme/child theme, then you can get the location via
    get_stylesheet_directory_uri()

    Please see the
    Codex Function Reference/get stylesheet directory uri

    http://codex.wordpress.org/Function_Reference/get_stylesheet_directory_uri

    for details.

    Hope this helps.

  3. preskoo
    Member
    Posted 1 year ago #

    Thanks for the response.

    When I use get_stylesheet_directory_uri() or even get_template_directory_uri() it links to the theme folder and not the php page.

  4. wpfan1000
    Member
    Posted 1 year ago #

    You can use something similar to:

    <img src="<?php echo get_stylesheet_directory_uri() ?>/images/aternus.png" alt="" title="" width="" height="" />

    This is the example that is on the page that I mention in my first post if you need more info.

    Your php file can be put in the theme folder and then replace /images/aternus.png above with your php file.

    btw I am not sure if it will work to put a php file in an anchor......

  5. preskoo
    Member
    Posted 1 year ago #

    Yes, this worked. Thank you so much.

  6. wpfan1000
    Member
    Posted 1 year ago #

    Glad you got it working :-)

Topic Closed

This topic has been closed to new replies.

About this Topic