2013-05-21, 07:16:57
I have been thinking about having slugs that dynamically output data from a plugin for various things, this is a pattern we use frequently.
Search output, blogs, category excerpts, galleries, anything dynamic.
I am not sure how some plugins do this, maybe I missed something obvious.
But
I believed there are 2 options but both boils down, you make a page where you want this to show up, basically a fake empty page, then you stick a inline shortcode in there to insert your plugins content, or the plugin uses a content filter which throws junk in your sidebar if you use getcontent, or it replaces global content on index-pretemplate hook. The page creation is usually left as an exercise left for the end user.
Most I have used involved a fake page sitting in your pages.
To have a completely fake page that does not exist you can do this. ( I beleive )
THIS WOULD ONLY WORK v3.2.1+
edited to fix var names,thanks angryboy
discuss
Search output, blogs, category excerpts, galleries, anything dynamic.
I am not sure how some plugins do this, maybe I missed something obvious.
But
I believed there are 2 options but both boils down, you make a page where you want this to show up, basically a fake empty page, then you stick a inline shortcode in there to insert your plugins content, or the plugin uses a content filter which throws junk in your sidebar if you use getcontent, or it replaces global content on index-pretemplate hook. The page creation is usually left as an exercise left for the end user.
Most I have used involved a fake page sitting in your pages.
To have a completely fake page that does not exist you can do this. ( I beleive )
THIS WOULD ONLY WORK v3.2.1+
PHP Code:
<?php
add_action('error-404','outputFakePage');
function outputFakePage(){
GLOBAL $id,$data_index;
if($id == "fake"){
$data_index->title = "fake";
$data_index->date = "";
$data_index->metak = "";
$data_index->meta = "";
$data_index->url = "fake"; // THIS IS THE IMPORTANT ONE TO OVERRIDE THE 404
$data_index->content = "fake output";
$data_index->parent = "";
$data_index->template = "";
$data_index->private = "";
}
}
?>
edited to fix var names,thanks angryboy
discuss