8598 readers
PHP
function add_custom_types_archive( $query ) {
if( is_category() || is_tag() && empty( $query->query_vars['suppress_filters'] ) ) {
$query->set( 'post_type', array(
'post', 'your-custom-post-type-here'
));
return $query;
}
}
add_filter( 'pre_get_posts', 'add_custom_types_archive' );
Visit wpsnipp.com for details on how to setup this WordPress snippet.
3140 readersWordPress 3.0 will allow you to create custom post types, so what about being able to list those custom types on your blog homepage? This very useful piece of code will show you how you can do it.Looking for WordPress hosting? Try WP Web Host. Prices starts at $5/month and you can try it for
16963 readers
PHP
function pdf_count(){
$query_pdf_args = array(
'post_type' => 'attachment',
'post_mime_type' =>'application/pdf',
'post_status' => 'inherit',
'posts_per_page' => -1,
);
$query_pdf = new WP_Query( $query_pdf_args );
echo $query_pdf->post_count;
}
PHP
Visit wpsnipp.com for details on how to setup this WordPress snippet. Share this post. Facebook | StumbleUpon | Delicious | Tweet It | Digg This | DesignBump-It | DesignPoke-it
4127 readers Some days ago, Frank wrote a post about Custom Pagination without WordPress Plugins. Jay comment, that something like this already exists (since Version 2.1). We don't know everything. How do you get it in your template? The best is, if you have a function, which you can use in several templates.
function my_paginate_links()
7281 readers
PHP
function img_count(){
$query_img_args = array(
'post_type' => 'attachment',
'post_mime_type' =>array(
'jpg|jpeg|jpe' => 'image/jpeg',
'gif' => 'image/gif',
'png' => 'image/png',
),
'post_status' => 'inherit',
'posts_per_page' => -1,
);
$query_img = new WP_Query( $query_img_args );
echo $query_img->post_count;
}
PHP
8211 readers
( example screenshot )PHP
add_action("admin_init", "pdf_init");
add_action('save_post', 'save_pdf_link');
function pdf_init(){
add_meta_box("my-pdf", "PDF Document", "pdf_link", "post", "normal", "low");
}
function pdf_link(){
global $post;
$custom = get_post_custom($post->ID);
$link = $custom["link"][0];
$count = 0;
echo '';
$query_pdf_args = array(
'post_type' => 'attachment',
'post_mime_type' =>'application/pdf',
'post_status' => 'inherit',
'posts_per_page' => -1,
);
$query_pdf = new WP_Query( $query_pdf_args );
$pdf = array();
echo '';
echo 'SELECT pdf FILE';
foreach ( $query_pdf->posts as $file) {
-
2133 readersIn a previous post I provide a solution on how to exclude certain categories from your feed. You can do the same with other content and I will show you in this post how you can exclude certain posts from your feed. Therefore I use the filter posts_where (wp-includes/query.php), which is responsible for the
10486 readers
PHP
function exclude_cat_wps($query) {
if ($query->is_feed) {
$query->set('cat','-20,-21,-22');
}
return $query;
}
add_filter('pre_get_posts','exclude_cat_wps');
Visit wpsnipp.com for details on how to setup this WordPress snippet. Share this post. Facebook | StumbleUpon | Delicious | Tweet It | Digg This | DesignBump-It |
3021 readersFinally! WordPress 3.0 was released last week. Among other exiting features, custom post types are bringing lots of new possibilities to bloggers. In this tutorial, I'll show you how to create a side blog listing products using the WordPress 3.0 custom post type feature.Like CatsWhoCode? If yes, don't hesitate to check my other blog CatsWhoBlog:
6695 readers
This snippet will do the job although it could use some tweaking that ill delve into in the future with an update. I found this much easier for clients to select images without going into the library and attaching images to posts.( example screenshot )PHP
add_action("admin_init", "images_init");
add_action('save_post', 'save_images_link');
function images_init(){
$post_types