• Resolved Kay Belardinelli

    (@kangabell)


    I have a custom post type called “event” that I’m trying to add using your instructions. Added this to my theme’s functions.php:

    function usp_modify_post_type($post_type) { 
    	return 'event';
    }
    add_filter('usp_post_type', 'usp_modify_post_type');

    However, in the plugin settings under “post type” I still only see “WP Post” and “WP Page” listed.

    The path for the admin edit page for this CPT is /wp-admin/edit.php?post_type=event, so I believe I have the slug correct, although I tried events as well for good measure.

    I am using the plugin “Very Simple Event List”, which is where the CPT is coming from.

    I am using latest version of User Submitted Posts (Version 9.9).

    How do I allow posts of this custom post type to be submitted?

Viewing 13 replies - 1 through 13 (of 13 total)
  • Plugin Author Jeff Starr

    (@specialk)

    I’m not familiar with the Very Simple Event List plugin, but can tell you that if you don’t see your CPT listed in the WP sidebar menu (along with Posts and Pages), then the CPT is not set up or configured correctly. That is the first thing to check.

    Thread Starter Kay Belardinelli

    (@kangabell)

    Thanks for the quick reply Jeff!

    The CPT itself works fine. It appears in the admin sidebar and I’ve been using it without issue. Here’s a screenshot showing the CPT in the sidebar, and lack of it represented in the dropdown: https://postimg.cc/R60bmSFZ

    Plugin Author Jeff Starr

    (@specialk)

    Alright great. And to be clear, what happens when you try to submit a post with the custom CPT function added to your theme? Does it post to the regular WP Posts, or just not at all?

    Thread Starter Kay Belardinelli

    (@kangabell)

    Yep it successfully comes in as a regular WP post.

    Plugin Author Jeff Starr

    (@specialk)

    Okay thanks. So I just retested that code snippet and it works on current/default WordPress. So if it is not working in this case the next thing to check would be that the name of the post-type slug is correct. For example, instead of event it might be events (plural), or maybe something else.

    Thread Starter Kay Belardinelli

    (@kangabell)

    Hmm I did try events as well (still didn’t work), but I’m pretty sure event is correct. I found this line in the plugin’s file to confirm:

    register_post_type( 'event', $vsel_args );

    Plugin Author Jeff Starr

    (@specialk)

    Hmm I don’t know then. Maybe check to make sure the function is included in the functions file of the current active theme. I know that sometimes I get mixed up and have to double-check.

    Thread Starter Kay Belardinelli

    (@kangabell)

    Hm yep it’s definitely in the right theme! I will try maybe doing this with a custom post type added another way and see if it’s somehow an issue with the Events plugin.

    Plugin Author Jeff Starr

    (@specialk)

    Yeah that is another good thing to check. Also, to see how it works normally, you can set up a default WP install, and then activate only USP and custom snippet. That will tell you if it the issue is due to a conflict with another plugin. Can also test the theme that way, etc.

    Thread Starter Kay Belardinelli

    (@kangabell)

    Okay I’ve done the following:

    deactivated ALL plugins except for User Submitted Posts.

    registered a new custom post type called “Books” in my theme using the following code snippet pulled from the WP codex:

    function codex_custom_init() {
        $args = array(
          'public' => true,
          'label'  => 'Books'
        );
        register_post_type( 'book', $args );
    }
    add_action( 'init', 'codex_custom_init' );

    however, in the plugin settings I still don’t see the CPT listed in the dropdown.

    anything else I can try?

    Thread Starter Kay Belardinelli

    (@kangabell)

    I’ve also tried switching to the twentynineteen wordpress theme, and added the code to the functions.php there. I’ve tried adding it both inside of the twentynineteen_setup function and just at the end of the file.

    I’ve also tried using both “book” and “books” on the “return” line. Here is the snippet again to clarify:

    function usp_modify_post_type($post_type) { 
    	return 'book';
    }
    add_filter('usp_post_type', 'usp_modify_post_type');
    Plugin Author Jeff Starr

    (@specialk)

    “in the plugin settings I still don’t see the CPT listed in the dropdown.”

    No the plugin settings aren’t changed by adding the custom function. The only thing that will happen with the function in place is that all submitted posts will be sent to the specified post type (e.g., event). So ignore the settings and try to submit a post to see the results of the added function.

    Thread Starter Kay Belardinelli

    (@kangabell)

    Ohhhhh I misunderstood. That’s why I sent the screenshot showing the dropdown. I didn’t realize it was automatic!

    It works!

    Thanks!

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Custom Post Type filter hook not working’ is closed to new replies.