WordPress.org

Forums

Custom Ask page in WordPress does not work (2 posts)

  1. captain.comic
    Member
    Posted 4 years ago #

    Hi,

    I am using wordpress to create blog similar to stackoverflow.com where users can ask questions. I decided that since my Ask page is "same all the time" I create a new page called ask.php. This page will contain the FORM. The problem is that i cannot link that page correctly.

    In the header template I give the link to my ask page. I believe this link links to custom php file in my themes folder wp-content\themes\mythemename

    <a href="<?php echo get_bloginfo('template_directory'); ?>/ask.php"> ask</a>

    For the sake of simplicity the contents of my Ask (ask.php) page is just 'diplay one header', no loop no footer etc.

    <?php get_header(); ?>

    The problem when i click on the ask link an empty page is opened. When i hover mouse over the link I can see the link is correct http://mysitename.com/wp-content/themes/own/index.php, where 'own' is my theme folder.

    And this this a problem I created different php pages and changed the link accordingly but always an empty page is opened. Even when I try to give link to index.php

  2. Chip Bennett
    Theme Review Admin
    Posted 4 years ago #

    That's not how you link Pages in WordPress.

    If you've created a custom Page template, ask.php, in your Theme directory, you then need to create a Page within WordPress to use that template file.

    From your Dashboard, go to Pages -> Add New Page

    On the Edit Page screen, change the "Page Template" from "default" to "ask". Give the Page a Title of "Ask" (can be whatever you want, but this is for the sake of the explanation here).

    Now Publish the Page.

    Now you should be able to access the Page via:

    <a href="<?php echo home_url(); ?>/ask"> ask</a>

Topic Closed

This topic has been closed to new replies.

About this Topic