Archive

Posts Tagged ‘Posts’

WordPress Plugin Posts – PHPCodezPosts

It can be used to list posts and the output can be managed from admin side

== Description ==

PHPCodez Posts lists posts . The output can be managed from the back end

Advatages
======
1) We can restrict the number posts
1) We can list post randomly
2) We can sort posts by its name,comment count or id
3) We can show comment count with posts
5) We can list post under the selected categories
6) We can exclude posts

== Installation ==

1. Upload the plugin folder to your /wp-content/plugins/ folder.

2. Go to the **Plugins** page and activate the plugin.

3. Go to appearance->widget area and drag the widget “PHPCodez Posts” to the widget area to have this on the sidebar .

Click here to download the plugin

EmailFacebookLinkedInMySpaceDiggTumblrStumbleUponShare

increase the number of posts in the listing page of admin side – wordpress

Add the below given code to “function.php” inside your theme folder

function adminPaginationLimit(){
global $per_page, $wp_query;
$per_page = 500;
$posts_per_page = 500;
$wp_query->query(‘showposts=’. $posts_per_page);
}
add_action(‘admin_head’, ‘adminPaginationLimit’);

EmailFacebookLinkedInMySpaceDiggTumblrStumbleUponShare
Categories: Wordpress Tags: , ,

WordPress query to fetch posts orders by date added as custom field

<?php
$postQuery = “SELECT distinct(wposts.post_title),cast(wpostmeta.meta_key as DATE),wposts.ID,wposts.post_content,wposts.post_date,wposts.comment_count
FROM $wpdb->posts wposts
LEFT JOIN $wpdb->term_relationships ON (wposts.ID = $wpdb->term_relationships.object_id)
LEFT JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)
LEFT JOIN $wpdb->postmeta AS wpostmeta ON wposts.ID = wpostmeta.post_id
WHERE wpostmeta.meta_key = ‘dvd_release_date’ AND $wpdb->term_taxonomy.taxonomy = ‘category’ AND $wpdb->term_taxonomy.term_id IN(’3952′)
ORDER BY wpostmeta.meta_value DESC LIMIT $itemPerPage”;

$postResults = $wpdb->get_results($postQuery, OBJECT);

foreach( $postResults as $post ) {
echo $post->post_title;
}
?>

EmailFacebookLinkedInMySpaceDiggTumblrStumbleUponShare
Categories: Wordpress Tags: , , ,

show post which belong to more than 1 given categories – wordpress

<?php query_posts(array(‘category__and’ => array(22,27))); ?>

EmailFacebookLinkedInMySpaceDiggTumblrStumbleUponShare
Categories: Wordpress Tags: , , ,

Print the substring of the post content – WordPress

<?php

$content = get_the_content();

echo substr(strip_tags($content), 0, 100);

?>

EmailFacebookLinkedInMySpaceDiggTumblrStumbleUponShare
Categories: Wordpress Tags: , ,

Categories of a post – WordPress

<?php

foreach((get_the_category(POST-ID)) as $category) {

echo  $category->cat_name;

}

?>

EmailFacebookLinkedInMySpaceDiggTumblrStumbleUponShare
Categories: Wordpress Tags: , , ,

WordPress query to fetch the pages

<?php
 global $wpdb;
 $querystr = " SELECT distinct(post_title) ,ID,post_title FROM $wpdb->posts
 WHERE post_type='page'  AND post_status='publish' ";
 $pageposts = $wpdb->get_results($querystr, OBJECT);
?>
EmailFacebookLinkedInMySpaceDiggTumblrStumbleUponShare
Categories: Wordpress Tags: , ,

WordPresss query to fetch the posts under the given categories

<?php
 global $wpdb;
 $const="4,8,7"; //category Ids
 $querystr = "SELECT distinct(wposts.post_title),wposts.ID  FROM $wpdb->posts
 wposts LEFT JOIN $wpdb->term_relationships ON (wposts.ID =
 $wpdb->term_relationships.object_id)
 LEFT JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id =
 $wpdb->term_taxonomy.term_taxonomy_id) WHERE $wpdb->term_taxonomy.taxonomy
 = 'category'  AND $wpdb->term_taxonomy.term_id IN($const) ORDER BY rand() ";
 $pageposts = $wpdb->get_results($querystr, OBJECT);
?>
EmailFacebookLinkedInMySpaceDiggTumblrStumbleUponShare
Categories: Wordpress Tags: , , ,

Switch to our mobile site