我正在使用WordPress插件,我需要创建一个简单的自定义页面,我将在其中显示自定义内容。除了一件事,一切都很好。在我的自定义页面中,在我使用get_footer()
添加的页脚之后,显示了一些博客帖子。我不知道从哪里添加它以及如何从页面中删除它?
这就是我添加页面和rewrite_rule
的方式function customop_custom_output() {
add_rewrite_tag( '%print-projects%', '([^&]+)' );
add_rewrite_rule('^print-projects/?','index.php?print-projects','top');
flush_rewrite_rules();
}
add_action( 'init', 'customop_custom_output' ));
function customop_display() {
if($_SERVER['REQUEST_URI'] == '/print-projects/'){
include 'frontend-form.php';
}
}
add_action( 'template_redirect', 'customop_display' );
前端-form.php的
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>My WordPress Plugin Front-end Page</title>
<?php
get_header();
?>
</head>
<body>
<div class="row">
<?php
if(isset($_SESSION['guest-projects'])){
echo '<h3>Print Saved Projects</h3>';
echo '<table clas="form-table">';
echo '<thead><tr><th>Preview</th><th>Name</th><th>Action</th></tr></thead>';
echo '<tbody class="projects-link">';
foreach ($_SESSION['guest-projects'] as $r) {
$url = add_query_arg(
[
'action' => 'pn_delete_guest_product',
'pn_guest_product_id' => $r['pn_id'],
'nonce' => wp_create_nonce("pn_delete_guest_product")
],
home_url()
);
echo sprintf('<tr><td>%s</td><td>%s</td><td>%s</td></tr>', '<img src="'. $this->get_pn_product_image($r['pn_id']) .'" />',
$r['name'], '<a class="pr-edit" href="' . $this->pn_edit_saved_project($r['pn_id']) . '">Edit</a> <a class="pr-delete" href='. esc_url($url) .'> Delete</a>');
}
echo '</tbody>';
echo '</table>';
}else{
echo '<h3>Print Saved Projects</h3>';
echo '<h4>No projects saved!</h4>';
}
?>
</div>
<?php
//call the wp foooter
get_footer();
?>
</body>
</html>
您能告诉我如何从此页面删除帖子吗?谢谢!