I am not familiar with PHP Syntax. Now i added JSON Plugin to my wordpress website and activate it.
When i open url to get_recent_post , it's fine. JSON data are showing.
But when i open get_post , it's only showing
{"status":"error","error":"Include 'id' or 'slug' var in your request."}
So i don't know how to add post id to that URL.
here is the pic. Another get_page , gate_date_posts, etc... links are same showing error.
How can i do it?
To display a post's ID, simply use the following PHP code within the WordPress loop:
<?php the_ID(); ?>
To return the ID, use the following PHP code within the WordPress loop:
<?php get_the_ID; ?>
To get a post's id outside of the WordPress loop use the following PHP code:
<?php global $post; $post->ID ?>
Hope that helps you.
http://yoursite.com/api/get_posts/
with the s
If you use the WordPress link and click on it, you will be fine.
Related
Specifically I would like the home link to return them to a landing page if they first landed on that landing page. So lets say they land on a city landing page, then they visit other pages on the site I would like if they hit the home page link on those pages to be sent back to the city landing page. Is this possible? If so please explain.
I don´t really understand what you want but you can create logics in php. Use sessions to save wether or not a user visited the site. If you want more information or a better answer write names for the pages and write exactly what the client does and what changes html should have
Edit
It´s not possible in html. You set a php session (for example $_SESSION['site']) to the URL of the site you want the user to return to. You got to use a server and php so you have to save a.html as a.php. Download for example xampp and put your files into the htdocs folder. Start the Apache server.
Lets say you have the follownig:
htdocs/
|- index.php
|- a.php
|- b.php
Add this to the beginning of index.php. This will return the user to the site you put into $_SESSION['site']:
<?php
session_start();
if (isset($_SESSION['site'])) {
header('Location: '.$_SESSION['site']);
exit();
}
?>
This is how you set the session. For example in page b.php:
<?php
session_start();
$_SESSION['site'] = '/b.php';
?>
or in a.php
<?php
session_start();
$_SESSION['site'] = '/a.php';
?>
If you want to delete the session you can for example make a site (htdocs/stop-session.php) with this code:
<?php
session_start();
session_destroy();
header('Location: /');
exit();
?>
Another way is JS but thats far more complicated in my eyes. You could use coockies there.
I hope it helps. If you want any changes comment
I have observed that when I execute the function:
Yii::$app->request->sendFile() within a row with a gridView, instead of launching the file, it shows it embedded in the HTML.
Then if I remove the Pjax::begin() and Pjax::end() borders that enclose the GridView, Then download works.
How can I work with both functionalities without losing one of them?
This was discussed at Yii2 the solution for now is to use this method:
<?php Pjax::begin([
'id' => 'list',
'linkSelector' => '#list a:not([data-pjax=0])'
]); ?>
custom js or simple link to your action with download
pjax link
<?php Pjax::end(); ?>
It looks like this feature may be included in future releases.
I wanna get the page which contains some php and some html code, like this:
Page url: ahax.php?some=1&any=2
Page content:
<?php
some php code
?>
some html
<?php
some php
?>
I always use "echo" in php file for ajax, now it contains more row of html and php code, it is foolish to use "echo".
<?
$url = 'http://www.google.com';
echo file_get_contents($url);
?>
Not sure that I understood what you want to know... however I hope this is what you are looking for. Please, clarify your question.
Also, have a look at this very helpful link.
Quick Question:
i use following code in my View Script to generate a link
<?=HTML::a("(".$player['player']->steam_id_32.")",['steam/','steamid'=>$player['player']->steam_id_32])?>
This is going to return following link
/web/steam/STEAM_0%3A0%3A96553432
how can i have it return
/web/steam/STEAM_0:0:96553432
i tried some thing but could not figure it out thank you
This behavior is by design. You can't really change this behavior, but you could use a workaround.
The code below first creates the url and then decodes it. Then create the link (<a>) with the previous created url.
$url = urldecode(Url::toRoute(['steam/', 'steamid' => 'aa:bb:cc']));
echo Html::a('title', $url);
I am new to web page development. Something I would like to do, is create a link to a sub-page, and have the text part of the link display the meta description of the sub-page dynamically. So if at some point I update the description of the sub page, then refresh the browser on the main page, that updated description will display automatically in the link. Any idea how to do that?
You will need php for this. Something like
<?php
$tags = get_meta_tags('http://www.yousite.com/');
$content = $tags['description'];
echo "".$content."";
?>