shortcode on non wordpress php file - php

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.

Related

CSS won't load because of the script given from the template

I've been looking for the answer I seek in many posts before. But none of them worked for me.
I'm learning CI currently and want to implement it with admin panel template called Clip-Two. I will give brief explaination about my problem.
Problem : In some of my pages the CSS works fine, however in some of the pages the partially loaded.
Below is my controller called Users.php
Users.php
Within this controller, i have two functions, mainly the first one is for index, and the second one is when i want to create a user.
In the first function, the CSS works fine. All the required CSS files are loaded shown below.
Index.php
However, in the second function, which have a new page, it only load partially of the whole CSS files.
Create.php
Below is my header template
header.php
The one that I highlight is the CSS file that doesnt loaded properly.
When I inspect the elements, the file path is wrong, shown below.
Elements
Below is my config file on base_url().
Base_url()
So, I'm confused, is it my base_url() went wrong or is it something else. Any help will be appreciated. Thanks in advance!.
Sorry I made a very long post, i just want everybody have a clear picture of my problem.
EDITED
I'm using admin template from Clip-Two
Below is the console error shown on my page.
Sorry I think my post is a bit misleading, I have edited my title and my problem
Problem : the jQuery from the template have the theme selector, so basically the jQuery could not find the path.
It shows that jQuery could not find the path.
Is this my problem lies on the jQuery?
Are you sure you are not manipulating with that stylesheet using JavaScript? (You have an id identifier on tag.)
Also, insted of <?php echo base_url()?>, try <?=base_url()?> it takes way less space.

how to put php code in a wordpress page

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/

Insert scripts in Drupal

I want to insert a script to a Drupal page. What I can find there's no footer.tpl.php or head.tpl.php. I can find the page.tpl.php and tried to insert the script there but with no luck. I just want to add the script to a specific page therefore I tried to hard code it into the body of that page but with no luck. Where do I insert a script tag, there's to themes installed as far as I know and it's Base and Garland.
Thanks!
The usual way of adding javascript to a page is using drupal_add_js. By default, if you specify a file to add, it will add it in the section of the markup.
reallyxloco is correct about using drupal_add_js to add your script. What you'd need to do is add that into your template.php file.
The tpl file that you are probably trying to locate is likely html.tpl.php but depending on your version of Drupal, that might be a core file.
I'm trying to use drupal_add_js and it works. The thing is for the script to work it has to be inserted in the footer which also works, but drupal adds a slash in front of the src like this "/http://www.example.js", trying to say that the script is a external script but without no success, here's the code I'm using:
<?php
drupal_add_js('http://example.com/example.js', 'module','footer',FALSE,FALSE,FALSE);
?>

Wordpress include php file

I am trying to create a php website on WordPress for the first time.
When I create a page, it creates a permalink which is of the form http://localhost/?p=123. I don't know if there is a corresponding file.
I've installed insert-php plugin to read php code. It works fine on a static page. But how do I include another php file? I want to include my_utilities which contains all the back-end functions, in login. It has a permalink 'http://localhost/?page_id=45'.
What to do?
include 'http://localhost/?page_id=45' doesn't work.
Pages you define in WordPress's backend are pages mostly setup for your users to view / read. They, by default, have this URL structure of http://localhost/?p=123 (though this can be changed, but that's a whole different lesson).
To include a script file, upload the file to your folder structure where you have your website then refer to it in your include statement as follows:
include('path/to/folder/my_script.php');
EDIT: You may also want to have a look into WordPress Page Templates:
Pages are one of WordPress's built-in Post Types. You'll probably want most of your website Pages to look about the same. Sometimes, though, you may need a specific Page, or a group of Pages, to display or behave differently. This is easily accomplished with Page Templates.
For exapmle your wordpress file is at
/var/www/html/wp-content/myphpfiles/test.php
To include the test.php file in your wordpress page you have to following.
[insert_php] include('wp-content/myphpfiles/test.php'); [/insert_php]
Thats it.

Wordpress: call php file?

basically I need to use the scripts at verify.php. however when I navigate to mysite.com/verify.php, wordpress page shows up and throws 404.
I need to send AJAX post to this file from jQuery in the main wordpress index page.
As well as in the future I will have some more somescript.php to load via URL and I need wordpress to not throw 404.
You can create a custom page template. Within the custom page template you can include your own php code.
Before anyone can answer your question, please verify what is "verify.php", is it a file that you upload to /[your-wordpress-folder]/ or a custom page template ?
maybe his will help you :
http://codex.wordpress.org/Template_Hierarchy
http://codex.wordpress.org/Pages#Page_Templates

Categories