Creating my own portfolio custom-type

Attachments are post objects, with post_parent set to the ID of the post they belong to (ie your ‘session’). The WP Codex page on wp_get_attachment_image() has an example almost exactly like what you’re trying to do: https://codex.wordpress.org/Function_Reference/wp_get_attachment_image#Display_all_images_as_a_list Make sure that you replace the post_parent parameter in that example with the ID of the current session … Read more

Custom Post Type Dilema – How do I categorise by country?

There are essentially two distinct approaches to this: countries as terms associated natively as taxonomy information as taxonomy meta (needs table created, see Metadata API) front-end display as taxonomy categories or countries as custom post type associated with post relationships (needs plugin sich as Posts 2 Posts) information as post + custom fields front-end display … Read more

sort post types by amount of views

WP post views plugin already does this job very well. So just install that plugin , then use function like this <?php if (function_exists(‘get_most_viewed’)): ?> <ul> <?php get_most_viewed(‘custom post type name’,20); ?> </ul> <?php endif; ?> For more info, check this FAQ page

How do you make a custom post type items automatically delete items 3 months after publication?

add_action( ‘wp’, ‘delete_expired_coupons_daily’ ); function delete_expired_coupons_daily() { if ( ! wp_next_scheduled( ‘delete_expired_coupons’ ) ) { wp_schedule_event( time(), ‘daily’, ‘delete_expired_coupons’); } } add_action( ‘delete_expired_coupons’, ‘delete_expired_coupons_callback’ ); function delete_expired_coupons_callback() { $args = array( ‘post_type’ => ‘coupon’, ‘posts_per_page’ => -1 ); $coupons = new WP_Query($args); if ($coupons->have_posts()): while($coupons->have_posts()): $coupons->the_post(); // get the post publish date $test = get_the_date(); … Read more

How do you create %post_type%/%postname%/ permalink structure?

Beyond the fact that disabling ‘pretty’ permalinks in the Settings > Permalink page disables pretty permalinks for all post types and taxonomies, the options do not effect custom post types or taxonomies. If you set the permalinks to blog/%postname% then your posts will have the structure: www.yoursite.com/blog/hello-world. On the other hand, when a post type … Read more

Custom post type causes php-error in php version 5.2.17

You have to rewrite your code without closures. It could look like this: function wpse54191_plugin_init() { add_post_type(‘Netherlands’, array( ‘supports’ => array(‘title’, ‘editor’, ‘thumbnail’, ‘comments’) )); } add_action(‘init’, ‘wpse54191_plugin_init’); /* Add Post Type */ function add_post_type($name, $args = array() ) { if ( !isset($name) ) return; $name = strtolower(str_replace(‘ ‘, ‘_’, $name)); $args = array_merge( array( … Read more