I have created custom page in wordpress and in the page I have a form where users can upload a banner, and input some text.
The code is working perfectly on a local server. The problem is when I transfer to the live page, it is displayed as text instead of working normally.
I have tried to search for the page in cPanel but have later realized the pages are not stored as normal pages but stored in a database.
Please help me how to make my form work.
You can't put a php code (this is a code not a content) as a post content from the admin panel. A php file must be created (or using the functions.php) to serve that page and put the code there.
Find and open the functions.php file. It is located under the wp-content/themes/yourthemename/ folder.
At the end of the file (but before the ?> symbols if exist) add this code
function custom_function_for_your_page() {
// put your php code here
}
add_shortcode( 'custom_functionality', 'custom_function_for_your_page' );
Now as you guess, you can put the php code right below this line // put your php code here.
This is a shortcode. Now you can put that shortcode into the page content.
Open that page from the admin panel, where you've tried to put the php code. Instead of that code put this [custom_functionality].
Good luck :) Tell me if it doesn't work, we'll try more.
Looks like you may need a plugin, here is one such plugin I know about:
https://wordpress.org/plugins/insert-php/
Related
I am new here and looking for some help to copy content from a specific page on another site.
I tried
$result get_file_contents('https://ncov.totok.ai/details');
echo print $result
something like.
Where I am trying to get.
I have a Wordpress website. because Wordpress does not allow us to use PHP code directly into posts and pages. therefore, I added a plugin called Insert PHP and some other to use their shortcodes into posts or page to run custom code.
when I save file and check preview, nothing shows there.
I would like to ask the professionals to advise the way to do it.
Result Page: how to copy the active result from this page
The first thing is that the code is written in HTML and now I am changing this code in Wordpress. I have a home page where I have created a top menu which has links to several other pages.
This is the code I used to link it:
facilities
This was working fine when I was doing in in HTML, but it's not working when I am opening my page in localhost. When I click it, it shows a message that no content is found.
You need to add base url at first. For wordpress, you can do this with get_template_directory_uri().'/facilities.php'
Here, i assumed 'facilities.php' is located on your base directory if there is more directory you need to add those too. Hope, it helps.
I'm trying to display a wordpress' plugin output with shortcode through do_shortcode().
It's gonna be displayed inside tooltip and the only way to call it, is by requesting a php file through ajax.
So I have a blank page called weather.php with the shortcode inside. Ofcourse it won't work like this since it's a non-wordpress file.
My question is.. what I have to insert in that file to make do_shortcode() work?
In other words.. wordpressize this page!
Thanks in advance!
Place this code at the top of the weather.php file
include_once("ADJUST/PATH/wp-load.php");
The wp-load.php file is found in the main directory of your WordPress installation.
I am new to SMF.
I just installed SMF on my website. I tried editing the index.template.php . After saving changes, it displays raw HTML and PHP on the browser. I tried fixing the prob by returning the the page back to the original state to no avail.
At the moment, everything is gibberish both frontend and backend.
Pls what do i do?
There should be at least an open tag at the top of the file (at the top of every .php file). Make sure you didn't remove this tag. Everything outside of a <?php is interpreted as normal text so if you have removed this it would explain your issue.
Also, being an ex-team member for SMF I can assure you its better to create a copy of the default theme, then make your edits to that theme. Then if you experience an error you can always pass a param in the url to reset to the default theme (in case you need to get into the admin area). To do so end the url with index.php?theme=1
I have a simple HTML form that posts to a PHP page, which will then return the user some content.
I want to take this PHP code and get my WordPress theme to wrap around it, so that appears like a normal page on my site. I can't find any resources on this - where do I begin?
You can create a new page template by uploading a PHP file which starts with the following:
<?php
/*
Template Name: Something
*/
?>
Then create a new page in WordPress, and look in the dropdown box for Template on the right (depending on what version you are using). Select that, and that newly created page can now have whatever PHP code in it you want. You'll probably want to copy the default page template (if one exists) as a starting point.
Find out the post ID / page ID of where you want your custom PHP code to go.
Assuming that where your custom code will go is in a post, you should create a file in your theme's folder called single-POSTID.php.
Assuming that where your custom code will go is in a page, you should create a file in your theme's folder called page-PAGEID.php.
Copy the base code from single.php or page.php into the newly created file, and you can insert your custom code in the new files. Form actions should usually be "#" and if your form isn't working appropriately, it's most likely because of one of your HTML form fields are used by WordPress to do something. (e.g. a textbox with the name of "comment" will not properly work under your code, since WordPress will think you're trying to add a comment).
If you do anything that requires database access, WordPress keeps the DB connection alive in your theme, so you don't need to connect to the database again. Unless of course, whatever you're trying to do is in a separate database other than the one WordPress is installed in.