PHP: Wordpress Test Page - php

The problem!
I have a Wordpress site up and running. I wanted to add a custom page, for example if I browse to site.com/mytest it would display just Hello world without any css etc.
What I've tried
I added a mytest.php file under var/www/wp-content/ and tried to browse to it. (The code simply echo a static text).
What I got was simply a 404 page by Wordpress.

To view the file you uploaded, browse: site.com/wp-content/mytest.php
If you just type site.com/mytest , wordpress will thin you are reffering to a page stored in the wp-database. Since it's not you cant view it.
To add the page in the menu, use custom menu and add as "Custom link".

You can make your page a wp custom page template by adding this at the top:
/*
Template Name:Your Page Name
*/
Then create a page in the wordpress dashboard pages and select your page template from the page template dropdown.

Related

While having WordPress site, how do I make a custom php web page viewable outside the WordPress environment?

I have a WordPress site where a client wanted to add a custom web page (ex. custompage.php) so that they go to example.com/custompage. This custom page is just HTML and not related to WordPress, but simply making that page with that address goes to a 404 error in WordPress. How do I allow custom web pages to be viewed before having a WordPress check, so to speak?
First you could add WP template tags on top of your PHP file so that WordPress will understand its a page template.
The file custompage.php must be inside your Custom/Child theme directory.
<?php
/**
* Template Name: custompage
*
*/?>
<html><head></head><body>
<p>Your html...<p>
Then in WordPress dashboard, create a new page with the title custompage to make sure the slug is generated as wanted but it can be edited.
For this new page, in page attributes, select the newly created page template custompage and publish it.
You will be able to access example.com/custompage with your beautifull html displaying.

WordPress: Adding home page (=latest posts page) to navigation properly

I have a WordPress template displaying the latest posts on the home page (www.mydomain.bla) as it is the default setting in WordPress:
Now, I want to add a link referring to my home page in my navigation (with Appearance -> Menus). The only way I found to do this is by adding a custom link referring to my domain.
Here's my problem:
Even though the link itself does the job, one thing is not working. When navigating to a single post (like www.mydomain.bla/a-single-post) the needed classes indicating the parent link (current-post-ancestor current-menu-parent current-post-parent) do not appear to a custom link like they would to if I had a "Post page" which is not the Homepage.
Is there a way to add a link referring to my posts-showing homepage properly?
Thanks a lot for your help!
Create a new template named "Our blog" and paste the code for posts in this template. Now add a new page named "HOME", select OUR BLOG template and publish the page. Now go to the reading section under the setting tab and change the setting from your latest posts to a single page and select your HOME page.
Now you can add page rather than adding a custom link in the menu.

How to make Wordpress Custom page

i m a newbie to wordpress. I have started theme development and encountered these problems. I think these kind of problem does have a solution, but i m not able to find it out.
I m trying to make a custom page. Uptill now i have made header, footer and main index page.
I see that whenever my theme is activated, I see these default index page, with header and footer assign to it.
I have also made some cutom about us , contact us pages using the Add Pages Functionality of wordpress.
My Problem:
1.Now I m trying to make custom product page where I will have more than 100 images on that pages, and then i can change the images, add the images and description and the link url in future. I have made some html code and put it in the text Tab . I can also see the images on the frontend of the Custom page. But my template breaks. Images goes up and description goes far below.
Also i wanted to add fancybox to all the images which are goin to be replaced or added. But again my template breaks.
So can we make custom.php page and do some coding or anything which you feel is the right way of doing it, Please let me know.
Firstly create product.php page in templates folder using below code on top
<?php
/*
Template Name: My Product Page
*/
get_header();
// write your code here
get_footer();
Then, assign the above template to the page in admin.
Then, that page you can call in menu.
For more detail, check here :- http://codex.wordpress.org/Page_Templates
Actually you don't really need to create a custom template for this unless if you are planing to use that same template on another page.
If your page name is products , just create a file called page-products.php in your theme root. and write your code inside that page.
If your planing to develop themes first be comfirtable with wp template hierarchy.
http://codex.wordpress.org/Template_Hierarchy

Link to custom php theme page in wordpress

I want to link a template php page (header.php) to a custom php page (cmenu.php) I made in the same theme.
I've searched on a lot of websites via google and also through the Wordpress Codex on how to accomplish this but I can't seem to find it.
In my header.php page I have a div which I want to have an url href link to my custom menu called cmenu.php. (I want to link it to that page to be more mobile friendly.)
I tried te following codes I found in the codex and google but none of them work:
get_cmenu()
get_template_part('cmenu')
Make the page you want to link to a template page and make a page and assign that template to it.
In a template page you can run all custom code you want.

WordPress how to add another page?

I am using the newest version of WordPress (version 2.8.4)
I'm wondering how I would add an additional page.
I have a navigation that looks something like this.
home | about us | contact us | ... etc.
I read somewhere to go to pages -> add new but it forces me to put the content within WordPress rather than edit a PHP file itself.
How would I be able to enter PHP in it? Is there something else I can do?
For example if you want to add home, "About us" pages:
You have to create template pages for this.
For this you need 3 files: header.php, index.php and footer.php.
If you are using an existing theme, you will find these three files in your theme folder itself.
For creating your home page, copy the following into your index.php file:
<?php get_header(); ?>
<body>
/* include whatever u want in ur body tag */
<?php get_footer(); ?>
index.php will be automatically assigned to home page.
For the "about us" page, create a file named aboutus.php (whatever name you want with .php
extension) and copy and paste this code.
<?php
/**
* Template Name: aboutus //don't forget to add this name according to ur page name
*
* Selectable from a dropdown menu on the edit page screen.
*/
?>
<?php get_header(); ?>
<body>
/* whatever u want in ur body tag */
<?php get_footer(); ?>
Then go to dashboard of your website or blog, there click pages->Add new,
give the Title as Home. Then click publish button on right side of the (Add new page) window.
Then, on left side of the screen, again click pages->add new, then enter title as "about us"
and then, in right side of this window, you will see a dropdown box named template, click the dropdown and select "about us" from it. Then click publish button.
Now we are going to create menus to appear in the website or blog. For this,
On left side of window,click Appearence->Menus.
On left side down of window you will see Pages heading, in that click Most
Recent, check home, aboutus pages and click Add to Menu button.
Then, the selected pages are displayed on right side and click Save Menu button on right corner.
Then, on left top corner, click your website or blog name to view your website with the two menus with their pages.
Create a Template in your theme folder, then set the page to use that.
If you want to do it without creating a Template, you may be able to use a plugin such as Exec-PHP, however this brings with it a bunch of possible security issues.
Why do you want a content page outside of Wordpress and outside of the WP loop? You still need to use a template and WP includes or you'll run into permalink problems.
You can make a WP page but exclude it from navigation, if that's what you're after, with something like Exclude Pages.
I'm a bit confused about what you're asking, but if what you're looking for is a way to have a link in your WordPress navigation that goes to a page you create outside of WordPress, you can use this plugin:
http://wordpress.org/extend/plugins/page-links-to/
If this and the other answers aren't any help, you might want to edit your question to clarify what you're trying to do with the php.
Good luck!

Categories