Populating a page with content from post custom fields

I suggest using shortcode, as this’ll easily allow you embed the song list anywhere in your content, in any page or post. UPDATE: I got a little carried away, and ended up with this! function song_list_shortcode( $attrs ) { $r = ( object )wp_parse_args( $attrs, array( ‘format’ => ‘%post_title – %link’, ‘link’ => ‘%song_key_name’, ‘key’ … Read more

Limit amount of results returned

$images = $wpdb->get_col(” SELECT ID FROM $wpdb->posts WHERE post_type=”attachment” AND ID in ($meta) ORDER BY menu_order ASC LIMIT 5 “); Like @Kaiser suggested you can specify a range (5th to 20th results, a total of 15 results are returned at max) like this: $images = $wpdb->get_col(” SELECT ID FROM $wpdb->posts WHERE post_type=”attachment” AND ID in … Read more

Custom Post Status Posts viewable to the public

I have been looking to do something like that with EditFlow, where a custom status will determine if the post shows up on the homepage via a get_posts() query. $promoted_posts = get_posts( array( ‘post_status’ => ‘promoted’ ) ); That works, but it looks like I’ll need to filter the WP Query on the single page … Read more

Change existing label in the admin bar with something else

Found my answer including my full solution: <?php /* Plugin Name: Rename Posts to News Description: Rename built in posts to be called News Version: 1.0 Author: Scott Cariss @ Philosophy Design Author URI: http://www.philosophydesign.com */ // Not a WordPress context? Stop. ! defined( ‘ABSPATH’ ) and exit; add_action( ‘init’, array ( ‘chg_Posts_to_News’, ‘init’ ) … Read more

deleting terms programmatically

You can use below to assign all posts to another term during deletion mentioned on same page.. “The $args ‘force_default’ will force the term supplied as default to be assigned even if the object was not going to be termless.” Other wise if there was only one term attached with post, post becomes term less.

add image map script to post

The post content is filtered by kses, but you can extend the list of allowed tags. A search in the plugin directory for kses shows some useful results. Try Extend KSES, it seems to be exactly what you need (I haven’t tested it): This plugin extends the HTML functionalify of the WordPress kses.php file, which … Read more

Different amount of posts on homepage than paged pages

You should use the pre_get_posts filter. You can exclude the homepage with ! is_front_page or ! is_home depending on your configuration. /** * Changes the number of posts per page if not is_home * * @author SFNdesign, Curtis McHale */ function wptt_change_posts_on_page( $query ) { if ( ! is_home() && $query->is_main_query() ) { $query->set( ‘posts_per_page’, … Read more

Remove post_tag from default post type, add custom taxonomy

to completely remove post tags: https://stackoverflow.com/a/8363082 if you want to remove post tags from posts, but keep on other custom post types: add_action( ‘init’, ‘my_register_post_tags’ ); function my_register_post_tags() { register_taxonomy( ‘post_tag’, array( ‘my_post_type_here’ ) ); } to add your own custom taxonomy to posts, use register_taxonomy, setting the $object_type parameter to post.