Sortable column containing numeric values for Custom Post Type at WordPress Backend

Try // 1. Register the column add_filter( ‘manage_edit-post_columns’, ‘price_column_register’ ); function price_column_register( $columns ) { $columns[‘price’] = __( ‘Price’, ‘theme’ ); return $columns; } // 2. Display the column content add_action( ‘manage_posts_custom_column’, ‘price_column_display’, 10, 2 ); function price_column_display( $column_name, $post_id ) { if ( ‘price’ != $column_name ) return; $price = get_post_meta($post_id, ‘price’, true); if … Read more

3 random images from custom post type, each in a div with a diffrent class

Getting different classes in the divs is relatively simple and mostly not a WordPress question, but there are WordPress bits to it that need comment. Truncated code reformatted for legibility: $classes = array( ‘side left’, ‘middle’, ‘side right’ ); $qry = new WP_Query( array( ‘post_type’=> ‘portfolio’, ‘posts_per_page’ => 3, ‘orderby’ => ‘rand’, ‘order’ => ‘ASC’ … Read more

Add an Outside Wrapper to my Header and Make it Full Width

This should do it. I can’t test it right now. I used the genesis_header_markup_open() and the genesis_header_markup_open() Genesis functions and renamed them wpse_121660_header_markup_open() and wpse_121660_header_markup_close(). Then called them instead of the Genesis functions and added your new <div> in them. /** Reposition header outside main wrap */ remove_action( ‘genesis_header’, ‘genesis_header_markup_open’, 5 ); remove_action( ‘genesis_header’, ‘genesis_do_header’ … Read more

Confused about Custom Post Types

What you describe is the typical use case for a custom post type. When you register your post type, set the has_archive argument to true and WordPress will generate a custom post type archive page, which will be the list of all your property posts. Normally, the number of property posts displayed will use your … Read more

get post types and plugin order

Post types in WordPress are not saved some where, they are registered everytime you request a page. So to get all post types, you have to wait untill all post types are registered. Normally, all post types are registered before the hook wp_loaded is fired. So change your code in something like this: add_action( ‘wp_loaded’, … Read more

Is This Code Efficient – Or is there a better way?

I’d recommend caching – generating the HTML mark-up and storing that in a cache, and using that rather then generating the list on each page load. Of course, the cache would have to cleared if a recipe is ever added, removed or changes title. add_shortcode(‘recipe_list’, ‘recipe_query’); function recipe_query( $atts, $content ){ //Get mark-up from cache … Read more

Page as Archive page

The WordPress Template Hierarchy for custom post type archive index pages provides the solution. Simply create a template file, named archive-{post-type}.php – which in your case would be archive-blog.php. WordPress will create the archive index automatically (provided you set ‘has_archive’ => true in your register_post_type() call), will use the archive-blog.php automatically, and pagination will work … Read more