Wordpress Coding

2
Wordpress display pagename in wordpress <?php query_posts('category_name=page_template&orde rby=post_date&order=ASC');?> <?php if(get_category_parents(get_query_var('cat' )) || get_the_category( $id ) == $pagename) { $r= get_category_parents(get_query_var('cat')); $p= $pagename; echo $r.$p; while (have_posts()) : the_post();?> <?php if(in_category('page_template')) { ?> <?php the_title();the_ content(); ?> <?php } ?> Display the custom fields in wordpress <?php if ( $keys = get_post_custom_keys() ) { echo "<ul class='post-meta'>\n"; foreach ( (array) $keys as $key ) { $keyt = trim($key); if ( is_protected_meta( $keyt, 'post' ) ) continue; $values = array_map('trim', get_post_cu stom_values($key)); $value = implode($values,', '); echo apply_filters('the_meta_key', "<l i><span class='post-meta-key'>$key:</span> $value< /li>\n", $key, $value); } echo "</ul>\n"; } ?>

description

Some basics coding for wordpress

Transcript of Wordpress Coding

Page 1: Wordpress Coding

Wordpress display pagename in wordpress

<?php query_posts('category_name=page_template&orderby=post_date&order=ASC');?> <?php if(get_category_parents(get_query_var('cat')) || get_the_category( $id ) == $pagename) {$r= get_category_parents(get_query_var('cat'));$p= $pagename;echo $r.$p;

while (have_posts()) : the_post();?> <?php if(in_category('page_template')) { ?> <?php the_title();the_content(); ?> <?php } ?>

Display the custom fields in wordpress

<?php if ( $keys = get_post_custom_keys() ) { echo "<ul class='post-meta'>\n"; foreach ( (array) $keys as $key ) { $keyt = trim($key); if ( is_protected_meta( $keyt, 'post' ) ) continue; $values = array_map('trim', get_post_custom_values($key)); $value = implode($values,', '); echo apply_filters('the_meta_key', "<li><span class='post-meta-key'>$key:</span> $value</li>\n", $key, $value); } echo "</ul>\n"; } ?>

Page 2: Wordpress Coding

It will display the parent category name using querypost of parentcategory name

<?php query_posts('category_name=page_template&orderby=post_date&order=ASC');?> <?php echo get_category_parents( get_query_var('cat') , true , '' ); echo get_category_parents(get_query_var('cat'));?>