0
votes

I created a custom theme for WordPress, and the folder only has the header, footer, index (which calls for the header and footer) and page PHP files until now.

What I'm trying to do is to show another WordPress page of my own site (that one we create at /wp-admin/post-new.php?post_type=page) which has an URL.

The codes I tried to use are below.

I was redirected to the page I wanted (http://localhost/wordpress/test-page/) on the browser correctly, but the page doesn't show the text I wrote at my WordPress page. Am I missing something?

index.php:

<?php get_header(); ?>

<a href="http://localhost/wordpress/test-page/">This is the WordPress Page URL</a></br>

<?php get_footer(); ?>

page.php:

<?php get_header(); ?>

<!-- Some code to show the WordPress Page -->

<?php get_footer(); ?>

I expect to show the WordPress page contents, using the header and footer styles I created.

EDIT: Just uploaded new images to illustrate what I meant. These are using WordPress standard theme. I'm trying to show that "test" page in my custom theme. But when I access that page by the URL, it doesn't show the "Test page" contents.

enter image description here

enter image description here

enter image description here

1
If you go the page-whatever.php route, the page you create needs to literally be called "Whatever". Look into template hierarchy. developer.wordpress.org/files/2014/10/… What you may consider is in your theme create a page.php and add your custom header and footer stuff there. That way, all pages share that template.disinfor
Welcome to Stack Overflow _ If you haven't already done so_ create the page that you want your link to point to. Then visit the page from the WP dashboard and look for the URL Wordpress created, towards the top of the page. (You can also edit the URL at this point) Use the edited URL for your link _ When you rebuild into production version of the site you'll need to recreate the pages and the linksinputforcolor
@inputforcolor When you rebuild into production version of the site you'll need to recreate the pages and the links what? Please explain this.disinfor
@disinfor _ When you rebuild into production you'll go through a complete install of Wordpress onto your domain _ This will necessitate you recreating the pages of your site via the dashboard and for Wordpress to set up new URLs for each page _ Any direct links to those pages would need changing to correspond with the new URLs _ I hope this helps : )inputforcolor
You do not have to do that. You know you can export and import the database, right?disinfor

1 Answers

0
votes

Just found out that my page.php file needed to have some functions to show the WordPress page I created, like in the example below:

<?php get_header(); ?>

<?php

// Title
single_post_title();

// Content
the_post();
the_content();

?>

<?php get_footer(); ?>