<?php
/**
* Template Name: Powenko Template
* Description: A Page Template that adds a sidebar to pages
*
* @package WordPress
* @subpackage Twenty_Eleven
* @since Twenty Eleven 1.0
*/
get_header(); ?>
<style type="text/css">
<!--
ol {
margin:10px;
padding: 10px;
list-style-type: decimal;
list-style-position: inside;
}
li {
margin-left: 30px;
padding-left: 10px;
}
-->
</style>
<div id="primary">
<div id="content" role="main">
<?php
// Create a simple array.
$m_PostArray = array(); //1, 2, 3, 4, 5);
/*
print_r($array);
// Now delete every item, but leave the array itself intact:
//print_r($array);
$result = count($array);
// Append an item (note that the new key is 5, instead of 0).
$array[$result] = 6;
print_r($array);
*/
?>
<?php
$this_page_id = get_query_var('page_id');
$page_id = $this_page_id; // 123 should be replaced with a specific Page's id from your site, which you can find by mousing over the link to edit that Page on the Manage Pages admin page. The id will be embedded in the query string of the URL, e.g. page.php?action=edit&post=123.
$page_data = get_page( $page_id ); // You must pass in a variable to the get_page function. If you pass in a value (e.g. get_page ( 123 ); ),
$t_content = apply_filters('the_content', $page_data->post_content);
// Provides: You should eat pizza, beer, and ice cream every day
$healthy = array("<p>", "<p>", " ");
$yummy = array("", "", "");
echo $t_content = str_replace($healthy, $yummy, $t_content);
function get_cat_self($parent,$args){
$cats = get_categories($args);
$ret = new stdClass;
foreach($cats as $cat){
if($cat->cat_ID==$parent){
/*
$id = $cat->cat_ID;
$ret->$id = $cat;
$ret->$id->children = get_cat_hierchy($id,$args);
*/
// parent;
return $cat;
}
}
return NULL;
// return $ret;
}
function get_cat_hierchy($parent,$args){
$cats = get_categories($args);
// print_r($cats);
$ret = new stdClass;
foreach($cats as $cat){
if($cat->parent==$parent){
$id = $cat->cat_ID;
$ret->$id = $cat;
$ret->$id->children = get_cat_hierchy($id,$args);
}
}
return $ret;
}
$args = array(
'type' => 'post',
'child_of' => 0,
'hide_empty' => false,
'hierarchical' => true,
'exclude' => '1'
);
////////////////
/*
stdClass Object (
[4] => stdClass Object (
[term_id] => 4
[name] => android
[slug] => android
[term_group] => 0
[term_taxonomy_id] => 4
[taxonomy] => category
[description] => [parent] => 3
[count] => 1
[cat_ID] => 4
[category_count] => 1
[category_description] =>
[cat_name] => android
[category_nicename] => android
[category_parent] => 3
[children] => stdClass Object ( ) ) [5] => stdClass Object ( [term_id] => 5 [name] => iOS [slug] => ios [term_group] => 0 [term_taxonomy_id] => 5 [taxonomy] => category [description] => [parent] => 3 [count] => 1 [cat_ID] => 5 [category_count] => 1 [category_description] => [cat_name] => iOS [category_nicename] => ios [category_parent] => 3 [children] => stdClass Object ( [6] => stdClass Object ( [term_id] => 6 [name] => ios level2 [slug] => ios-level2 [term_group] => 0 [term_taxonomy_id] => 6 [taxonomy] => category [description] => [parent] => 5 [count] => 1 [cat_ID] => 6 [category_count] => 1 [category_description] => [cat_name] => ios level2 [category_nicename] => ios-level2 [category_parent] => 5 [children] => stdClass Object ( ) ) ) ) )
*/
if($t_content==""){$t_content="0";}
$t_parent=(int)$t_content;
// $t_parentID=get_cat_self($t_parent,$args);
// echo $t_parentID2=$t_parentID->parent;
Display_cat_self_posts_and_Under($t_parent,$args,1,true);
function Display_cat_self_posts_and_Under($parent,$args,$i_space){
$retarray=get_cat_self($parent,$args);
echo "<h1 id=".$retarray->term_id."'>";
echo "<a href='?cat=".$retarray->term_id."'> ".$retarray->name." </a>";
echo "</h1>";
Display_Posts($retarray->term_id);
//////
Display_cat_Under_Cat_and_posts($parent,$args,0);
}
function Display_cat_Under_Cat_and_posts($parent,$args,$i_space){
$retarray=get_cat_hierchy($parent,$args);
//print_r($retarray);
foreach($retarray as $airport)
{
echo "<h1 id=".$airport->term_id."'>";
echo "<a href='?cat=".$airport->term_id."'> ".$airport->name." </a>";
echo "</h1>";
Display_Posts($airport->term_id);
$t_space=$i_space+1;
// foreach($airport->children as $airport2) {
if($airport->children!=NULL){
// echo $airport2->term_id;
Display_cat_Under_Cat_and_posts($airport->term_id ,$args,$t_space);
}
}
}
function Display_cat_self_posts($parent,$args,$i_space){
$retarray=get_cat_self($parent,$args);
echo "<h1 id=".$retarray->term_id."'>";
echo "<a href='?cat=".$retarray->term_id."'> ".$retarray->name." </a>";
echo "</h1>";
Display_Posts($retarray->term_id);
}
function Display_Posts($t_id){
$argsposts = array('numberposts' => 2000,'offset'=> 0,'category' =>$t_id, // $airport2->term_id,
'orderby'=> 'post_date','order'=> 'DESC','post_type' => 'post',
'post_status' => 'publish' );
$postslist = get_posts( $argsposts );
echo "<ol>";
foreach ($postslist as $post) : setup_postdata($post);
echo "<li><a href='?p=".$post->ID."'>";
for($i=0;$i<$i_space;$i++){
echo " ";
}
$image_url = get_the_post_thumbnail_src(get_the_post_thumbnail( $post->ID));
echo '<img src="'.$image_url.'" width="60" height="60" alt="'.$post->post_title.'">';
echo $post->post_title."</a></li>";
endforeach;
echo "</ol>";
}
/*
function Display_cat_under_posts($parent,$args,$i_space){
$retarray=get_cat_hierchy($parent,$args);
print_r($retarray);
foreach($retarray as $airport) {
foreach($airport->children as $airport2)
{
echo "<h".$i_space." id=".$airport2->term_id."' >";
echo "<ol>";
for($i=0;$i<$i_space;$i++){
echo ".";
}
echo $airport2->name."<a href='?cat=".$airport2->term_id."'> Cate </a>";
echo "</h".$i_space.">";
$argsposts = array(
'numberposts' => 2000,
'offset' => 0,
'category' => $airport2->term_id,
'orderby' => 'post_date',
'order' => 'DESC',
'post_type' => 'post',
'post_status' => 'publish' );
$postslist = get_posts( $argsposts );
echo "<ol>";
foreach ($postslist as $post) : setup_postdata($post);
echo "<li><a href='?p=".$post->ID."'>";
for($i=0;$i<$i_space;$i++){
echo " ";
}
$image_url = get_the_post_thumbnail_src(get_the_post_thumbnail( $post->ID));
echo '<img src="'.$image_url.'" width="60" height="60" alt="'.$post->post_title.'">';
echo $post->post_title."</a></li>";
endforeach;
echo "</ol>";
$t_space=$i_space+1;
foreach($airport2->children as $airport3)
{
Display_cat_under_posts( $airport->term_id ,$args,$t_space);
}
echo "</ol>";
}
}
}
*/
function get_the_post_thumbnail_src($img)
{
return (preg_match('~\bsrc="([^"]++)"~', $img, $matches)) ? $matches[1] : '';
}
////////////////////
?>
<?php
/*
stdClass Object (
[ID] => 15
[post_author] => 1
[post_date] => 2012-01-29 06:40:54
[post_date_gmt] => 2012-01-29 06:40:54
[post_content] => i love android content
[post_title] => i love android title
[post_excerpt] =>
[post_status] => publish
[comment_status] => open
[ping_status] => open
[post_password] =>
[post_name] => android
[to_ping] => [pinged] =>
[post_modified] => 2012-02-01 07:36:34
[post_modified_gmt] => 2012-02-01 07:36:34
[post_content_filtered] =>
[post_parent] => 0
[guid] => http://localhost/wordpress/?p=15
[menu_order] => 0
[post_type] => post [post_mime_type] => [comment_count] => 0 [filter] => raw )
////////////////
[ID] => 23
[post_author] => 1
[post_date] => 2012-02-01 18:00:34
[post_date_gmt] => 2012-02-01 18:00:34
[post_content] => ios test2
[post_title] => ios test2
[post_excerpt] =>
[post_status] => publish [comment_status] => open
[ping_status] => open [post_password] =>
[post_name] => ios-test2
[to_ping] => [pinged] =>
[post_modified] => 2012-02-01 18:00:34
[post_modified_gmt] => 2012-02-01 18:00:34
[post_content_filtered] =>
[post_parent] => 0 [guid] => http://localhost/wordpress/?p=23
[menu_order] => 0 [post_type] => post [post_mime_type] =>
[comment_count] => 0 [filter] => raw
*/
/*
stdClass Object (
[3] => stdClass Object (
[term_id] => 3
[name] => IT
[slug] => it
[term_group] => 0
[term_taxonomy_id] => 3
[taxonomy] => category
[description] => [parent] => 0 [count] => 1 [cat_ID] => 3
[category_count] => 1
[category_description] => [cat_name] => IT [category_nicename] => it [category_parent] => 0
[children] => stdClass Object (
[4] => stdClass Object (
[term_id] => 4
[name] => android
[slug] => android
[term_group] => 0
[term_taxonomy_id] => 4
[taxonomy] => category
[description] =>
[parent] => 3 [count] => 1
[cat_ID] => 4 [category_count] => 1
[category_description] =>
[cat_name] => android
[category_nicename] => android
[category_parent] => 3
[children] => stdClass Object ( ) )
[5] => stdClass Object (
[term_id] => 5
[name] => iOS
[slug] => ios
[term_group] => 0
[term_taxonomy_id] => 5
[taxonomy] => category
[description] =>
[parent] => 3
[count] => 1
[cat_ID] => 5
[category_count] => 1
[category_description] =>
[cat_name] => iOS
[category_nicename] => ios
[category_parent] => 3
[children] => stdClass Object ( ) ) ) ) )
*/
echo "<p><p><p><p>";
?>
<?php $image = get_post_meta($post->ID, 'thumbnail', true); ?>
<img src="<?php echo $image; ?>" title="<?php the_title(); ?>" />
<?php the_post_thumbnail(); ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', 'page' ); ?>
<?php comments_template( '', true ); ?>
<?php endwhile; // end of the loop. ?>
</div><!-- #content -->
</div><!-- #primary -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
Post navigation