How to copy content from another site actively? - php

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

Related

Adding archive pages to CMS

(I am not sure if this is the proper place for this post. If not, just let me know where to repost it. I don't have a lot of experience with PHP. I 'know' just enough to be dangerous.)
I am using the CMS, HTMLy, and am trying to list the archives on a separate page, instead of a side column.
In the main page the following command is used to display the archives in the column:
<?php echo archive_list() ?>
However, I am having a problem getting the PHP to display the list on a web page. The system uses markdown (.md) so I can't run it from there.
Any suggestions?

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/

Category specific calendar in wordpress (get_calendar)

I cannot find a category specific calendar, or any sample code to allow me to get slightly dirty... Anyone know of a category specific calendar so I can call it for example:
get_calendar(true, true, $cat_id);
Otherwise I will have to copy the get_calendar function and make my own get post by category loops sigh
Ended up making my own calendar.
This is a really shaky way of doing it but it works great.
Create a new page in your template directory called “the-calendar.php” place the following code in it: http://pastebin.com/sUSzJMWM
Create a new script file (that has access to jquery).
Put the following code in it
(MAKE SURE YOU HAVE SET site_url to equal “get_template(‘blog_info’) . ‘/’”): http://pastebin.com/Q16ibAZ0
Now just include this wherever you want the calendar to be (keeping in mind that the above script must be accessible):
http://pastebin.com/fyhXrCiW
Don’t forget to style your date.php page in your wordpress theme directory!!!
Here is some default styling that looks awful but should get you started:
http://pastebin.com/NMauFJWq
The Calendar works by calling (via AJAX) an external PHP file that gathers and echos the HTML code that generates the table. On the success of the AJAX, it just fills the specific div with the returning html.
Please feel free to expand on the code and also ask questions if you can’t get it to work! I hope it saves you some time!

How to add dynamicly linked and created pages in wordpress?

Since I had some comments on the formulation of my question, I decided to rewrite it completely. And also, I understand a little bit more about wordpress so it should make more sense now.
So, let's start with what I'm trying to accomplish by using a simple example:
Goal:
Make a search engine for some products and link to them using a database to generate the information.
Result:
http://my.site.url/wordpress/<plugin-name> <-- The page with the "search" and "search result
http://my.site.url/wordpress/<plugin-name>/products/<product_name> <-- When click on a search result
Part 1:
I want to make a plugin with the name "plugin-name" Right now, I put my code in
http://my.site.url/wordpress/wp-content/plugins/<plugin-name>
On the activate, I create some tables with some data. Since there is no page yet, I create 1 on the fly using the API call 'wp_insert_post'. I give the name and slug "myPlugin".
So, when I go on the main site, I can see my newly created page "myPlugin". But right now, there is no content attached to it. To do so, from what I understand, I need to create a page in my plug-in directory named "myPlugin.php".
http://my.site.url/wordpress/wp-content/plugins/<plugin-name>/myPlugin.php
So, how do I link the page I created manually and the source file in the plugin directory?
Part 2
When clicking on a link in the search result, I would like to have a page "product.php" and display its information. So, is it possible to create a "temporary url" for the result using sub pages (see result at the beginning)? And if possible, how can we achieve that?
Thanks in advance and I hope it's clearer.
u can find how to create plugin from
http://ditio.net/2007/08/09/how-to-create-wordpress-plugin-from-a-scratch/
in plugin write function for search(as per u r logic) fetch result
create a custom page refer video from www.wordpressmax.com/customize-wordpress/custom-page
in custom pages template in between get_header(); and get_footer(); call search function and display records.
Thats it.
thisMayhem is right. This sounds like a bunch of nonsense. But, if you're trying to make a WP page that executes some custom PHP, look up the WP template hierarchy.
What you can do is this:
create a WP "page" - call it "Search results."
create a template directory file called page-search-results.php (filename corresponds with slug of page from step 1)
put some generic header/footer stuff there (see other template files - most often it's just a question of putting in <?php get_header(); ?> and <?php get_footer(); ?>)
put PHP code in that thar page. in them hills.
if you use a caching plugin, may want to put an exemption for /search-results/
So, when someone pulls up http://your.site/search-results/ - your custom PHP code will execute. It's up to you to make that logic and communication happen - whether via $_GET or $_POST, etc.
I'm sorry you're experiencing some problems. Unfortunately as we say above because it's a 'one off' for a client project we can't support it - it works for them :) Feel free to rip it apart and retest and if you have any success let us know.

How can I integrate PHP code into a WordPress page?

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.

Categories