我想编写一个自定义的next/prev函数来动态显示fancybox弹出窗口中的帖子信息.因此,我需要使用PHP来根据Post当前显示的内容获取下一个和之前的帖子ID.我知道当前的帖子ID是什么,我可以将其发送到函数ok,但我无法弄清楚如何使用该ID来获取相邻的ID.
编辑:这是我的代码到目前为止(这是不行的)
<?php
require_once("../../../wp-blog-header.php");
if (isset($_POST['data'])){
$post_id = $_POST['data'];
}else{
$post_id = "";
}
$wp_query->is_single = true;
$this_post = get_post($post_id);
$in_same_cat = false;
$excluded_categories = '';
$previous = false;
$next_post = get_adjacent_post($in_same_cat,$excluded_categories,$previous);
$post_id = $next_post->id;
$title = $next_post->post_title;
$dataset = array ( "postid"=>$post_id, "posttitle"=>$title );
//Because we want to use json, we have to place things in an array and encode it for json.
//This will give us a nice javascript object on the front side.
echo json_encode($dataset);
?>
Run Code Online (Sandbox Code Playgroud) 如果我使用HTML5文档类型,则在Mac上的Chrome,Safari或Firefox中呈现页面时
<!DOCTYPE html>
Run Code Online (Sandbox Code Playgroud)
并将图像放在div中,div一直呈现4像素太高.如果我使用较旧的doctype
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Run Code Online (Sandbox Code Playgroud)
正确渲染div,其高度与其中的图像相同.这是使用完全相同的HTML和CSS代码.唯一改变的是doctype和额外的4个像素.有没有什么办法解决这一问题?
我有几个我想在页面上布局的SVG图像.Firefox和Chrome没有给我任何问题,但当且仅当文档具有".xhtml"扩展名时,Safari才会显示SVG图像.如果我尝试使用PHP代码(以及".php"扩展名),我在".xhtml"文档中使用的完全相同的标记将不再显示SVG图像.问题当然是,我必须使用PHP来完成手头的项目.有什么建议?这是源代码:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:lang="de" xmlns:xml="http://www.w3.org/XML/1998/namespace">
<head>
<title>SVG Safari Test</title>
</head>
<body>
<!-- Generator: Adobe Illustrator 15.0.2, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="500px" height="500px" viewBox="0 0 500 500" enable-background="new 0 0 500 500" xml:space="preserve"><circle cx="250" cy="250" r="238.048"/></svg>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)