Custom Fields for Page Edits

Typically what plugin authors will do is use add_meta_box to add an area on the post edit screen for users to enter extra data. Within the functions that save and retrieve the data to generate your meta box, use the post meta functions to store it. Remember that prefixing a meta key with an underscore … Read more

Custom wpdb query – how to sort post by another table meta_count

<?php $querystr = “SELECT {$wpdb->posts}.ID, {$wpdb->posts}.post_title, {$wpdb->prefix}stt2_meta.meta_count FROM {$wpdb->posts}, {$wpdb->prefix}stt2_meta WHERE {$wpdb->posts}.post_type=”post” AND {$wpdb->posts}.post_status=”publish” AND {$wpdb->posts}.ID IN ( SELECT post_id FROM {$wpdb->prefix}stt2_meta ) ORDER BY {$wpdb->prefix}stt2_meta.meta_count DESC LIMIT 10;”; $pageposts = $wpdb->get_results($querystr, OBJECT); ?>

How to display posttypes and taxonomy in standard posts, not in a separate label?

when you register a taxonomy, the second argument is the post type it is available for: register_taxonomy( $taxonomy, $object_type, $args ); if you want the taxonomy to work for a custom type as well as standard posts, you can pass an array of types: $object_type = array( ‘your_custom_type’, ‘post’ ); alternately, you can use register_taxonomy_for_object_type: … Read more