how to add google news feed in your websites using PHP

Here we are going to discus how to add google news feed in your websites using PHP ,we know that google is proving XML for news feed here is the link for that

https://news.google.com/rss/search?q=KEYWORD

Here KEYWORD is search query what we are going to add as news feed in your website

This link output xml formatted news feed from that latest websites we can use same xml in your site ,we can use PHP function to convert from one suitable format

Suppose we need to display Cricket World Cup news feed in your website you have to replace KEYWORD with ‘Cricket World Cup’ see example API link below

https://news.google.com/rss/search?q=Cricket+World+Cup&hl=en-IN&gl=IN&ceid=IN:en

Next Step to get the data from the XML

we need to use simplexml_load_file for that

See below code

 


$xml=simplexml_load_file("https://news.google.com/rss/search?q=Cricket+World+Cup&hl=en-IN&gl=IN&ceid=IN:en");
$arrayG = json_decode(json_encode((array)$xml), TRUE);

TO display latest 10 item we have to use

$arrayFeed=array_slice($arrayG['channel']['item'], 0,2);
foreach($arrayFeed as $key=>$value)
{

echo "</pre>
<div class="col-md-9 nfspara">".$value['description']."</div>
"; }

see demo out from the below link
News Feed

Out Put

add google news feed in your websites using PHP

how to redirect all dynamic pages to single php page using .htaccess

In core PHP sometimes we need to create dynamic pages for all the post added in the backed,if we have hundreds of post we don’t want to create 100 pages to display all the post.Here am going to display how we can use slug to identity each post and pass that slug in the URL suppose we have to create a URL like post_POSTNAME_page.so each post having the same URL structure we will replace POSTNAME with slug, that we created from the post tile or post name
so i want to call all post_POSTNAME_page to a single php page ,we can do it with the help of .htaccess .in the below post am going to explain you how to redirect all dynamic pages to single php page using .htaccess. First i need to create a php page name postpage.php
In the postpage.php we can get the value of slug by using the get method

$page_slug=$_GET[‘slug’];

by using this page slug we can use mysql to fetch all data related to that post

Here is the rules to redirect all dynamic pages to single php page using .htaccess


RewriteEngine On
Options +FollowSymLinks
RewriteRule post_(.*)_page$   postpage.php?slug=$1

See how it going to work

https://www.tutorialshore.com/post_Indian_history_page

It will call postpage.php?slug=indian_history

So if we use $_GET[‘slug’], we will get page slug Indian_history by using this slug we can access the post content for Indian history
same way you can add pages also

RewriteRule page_(.*)_content$ page.php?slug=$1

All inside pages are redirecting to http://localhost/dashboard/ in WordPress xampp localhost

When we install WordPress in localhost may face an issue,All inside pages are redirecting to http://localhost/dashboard/ in WordPress localhost

suppose we installed a working WordPress site inside demo folder in htdocs directory and changed the wp_option table siteurl and home option value to http://localhost/demo/

Here is my .htaccess files


RewriteEngine On
RewriteBase /
RewriteRule ^index\.php?$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

here http://localhost/demo/contact_us it is redirecting to http://localhost/dashboard/

To fix this issue you have to change .htaccess files like this

added below code in .htaccess files
RewriteBase /demo/
RewriteRule . /demo/index.php [L]

Here is the .htaccess files


RewriteEngine On
RewriteBase /demo/
RewriteRule ^index\.php?$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /demo/index.php [L]

call from below number to check your account balance

To do HDFC Bank Balance Enquiry, you can give a call to –

1800-270-3333

To do SBI Bank Balance Enquiry, you can give a call to –

18004253800

To do CANARA BANK Balance Enquiry, you can give a call to –

09015483483

To do Punjab National Bank Balance Enquiry, you can give a call to –

1800 180 2223

To do ICICI Bank Balance Enquiry, you can give a call to –

9594 612 612

To do Bank of India Balance Enquiry, you can give a call to –

09015135135