chrisarnoldco
Forum Replies Created
-
@danieliser All working now! Thanks for you help.
@danieliser I’ve downloaded and tested the changes and my custom post type is now working so thank you!
However the popup is still not showing on the Archive page… the modifier is being set to
index
but theswitch
statement within thepost_type
function doesn’t contain acase 'index':
so it’s always returningfalse
.Thanks for the tip re. post types being singular by the way ??
No that’s cool. Each post type has it’s own custom fields and taxonomies, trying to keep them all under the
post
post type would just get too unwieldy. Plus when the client logs in it’s much clearer for them to see where they need to add their content, having them all under Posts will mean they’ll need to remember to select the category, add data to the correct fields etc etc.Okay great, let me know if you need anything else.
The site has 7 custom post types and the
post
post type is being used for News and Events. They then asked for a blog to be added to the site so we created a new post type and named itblog_post
.The code I used for to register the post type is below…
function ns_blog_posttype() { register_post_type( 'blog_posts', array( 'labels' => array( 'name' => __( 'Blog' ), 'singular_name' => __( 'Blog' ), 'add_new' => __( 'Add New Blog' ), 'add_new_item' => __( 'Add New Blog' ), 'edit_item' => __( 'Edit Blog' ), 'new_item' => __( 'Add New Blog' ), 'view_item' => __( 'View Blog' ), 'all_items' => __( 'All Blog' ), 'search_items' => __( 'Search Blog' ), 'not_found' => __( 'No Blogs found' ), 'not_found_in_trash' => __( 'No Blogs found in trash' ) ), 'public' => true, 'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail' ), 'rewrite' => array("slug" => "blog", "with_front" => false), // Permalinks format 'menu_icon' => 'dashicons-admin-page', 'menu_position' => 30, 'has_archive' => true ) ); } add_action( 'init', 'ns_blog_posttype' );
I’ve been having the same issue too. Looking at the function you posted above @danieliser it looks like mine is breaking due to the custom post type being named as ‘blog_post’. What’s then being stored in
$post_type
is actually ‘blog’ and not ‘blog_post’.Also when I select ‘Blog Archives’ as one of the conditions for my popup the
$modifier
variable is set to ‘index’ but looking at theswitch
statement in that function that doesn’t exist?