• Resolved swtyndall

    (@swtyndall)


    I inherited support for a blog that was set up by another developer. They used ACF to create custom fields and a group and though CPT UI was already installed, this CPT is not registered with it. I have been banging my head against the wall trying to find the “template” that generates the CPT edit/create screen and displays the CPT for users. The blog is based on a Neve Child theme and perhaps that is where the CPT was created and registered but I can’t figure out how to edit it, perhaps it was created in the Pro version of the theme and we only have the free version now. I am using Elementor Pro and there is ACF already installed as well as CPT UI on the blog. I can find the PHP file for this CPT, and edit some of the static text that surrounds the custom fields, but not really knowing PHP, I want to use elementor to style and edit any changes in the static text on the CPT. The field group shows up in ACF, but that doesn’t help me edit it. Trying my best to help a friend with their site but struggling. Any assistance or suggestions you have are greatly appreciated!!

    The page I need help with: [log in to see the link]

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Let’s take a step back and start off with a couple of questions.

    1. Are you trying to locate where this specific post type is being registered, so you can change some aspects of that registration? For example, you want to make it hierarchical so that you can assign parent/child relationships between the posts?

    2. What’s the slug of the post type, or types, for any in question. The link makes me believe that there’s at least a “weekly” post type right now.

    Thread Starter swtyndall

    (@swtyndall)

    Thank you for the quick response, Michael!

    Question 1. Yes I am trying to locate where it is being registered. For some reason it doesn’t appear to be editable by elementor pro, and from what research I have done, this appears to be because of how it is registered. I am fairly PHP illiterate, and I need to be able to edit the static text that surrounds the custom fields and perhaps add more custom fields and right now, the only way I can figure out how to do that for now is by editing the PHP file for this CPT–a far less than ideal situation.

    When I inherited this site, CPT UI was installed, yet this “weekly” CPT was not registered with it. What would account for the inability to edit this CPT in elementor pro? Perhaps it needs to be registered instead with CPT UI or the registration was done incorrectly and that needs to be edited. I haven’t been able to figure it out…

    Also certain archives don’t work for this CPT. I’ve tried numerous different plugins that allow you to specify post type, and displaying recent posts, works fine. When I try to display a categories archive, it retrieves the categories yet when you click on the category to go to a list of posts, it can’t find or display any of the posts in that category. Same thing for a month based archive, it shows the months that posts have been created in, yet the links take you to a page that says nothing can be found. Also, search doesn’t appear to work correctly with this CPT, which by the way is the only post type being used on the site.

    Question 2 The Weekly post type is the only one in use and the only one giving me problems. Is the slug “Weekly”? I’m having trouble figuring out how to determine the slug. In some places it appears to refer to it as “Weekly Posts”.

    Any suggestions you have are greatly appreciated!!!!

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Overall, it sounds like a lot of custom development has gone into things here.

    I have never known Elementor Pro to also be a way to register post types, but I could be wrong.

    Nothing *needs* to be registered via CPTUI, however we are a very elegant way to do so 🙂 The presence of the plugin could be a case of someone thought of using it, but then decided not to, and forgot to uninstall. No way for me to know for certain.

    The fact that the post type is registered in general means it’s registered in one of many possible correct ways. The real question is *where* is it being registered from. If I was in the situation, I would very likely download a copy of the theme and just do a “find” within a text editor for “register_post_type” and check for any found results. If found, I’d know files to check out and review at that point. It could also be in a plugin though, so perhaps review that list and look for any that look custom for this site specifically. For example you could easily ignore WordPress SEO for where to check, as that’s not going to be a custom one.

    The rest of the issues sound like trying to get this post type into the various archives, which would likely be using things like the pre_get_posts hook, however I am not able to verify. This could also be spots making use of Elementor Pro, which would probably be questions better for their support.

    Regarding just identifying the slug, when you go to create a brand new post in this post type, the slug will be in the address bar, likely something like post_type=weekly or similar.

    Thread Starter swtyndall

    (@swtyndall)

    I was looking at the functions.php file and I suspect something may be a bit off about it. I see cptui referenced a few times and I see where the CPT appears to be called “Weekly” in certain places and “Weekly post” in others. Not familiar enough with how PHP and this neve child theme file works to really understand what I am seeing. I did notice that has archive was false, so I changed to true to see if the archives might start working.

    Here’s the text of the functions.php file:

    <?php

    if ( ! defined( ‘ABSPATH’ ) ) {
    exit;
    }
    if ( ! function_exists( ‘neve_child_load_css’ ) ):
    /**
    * Load CSS file.
    */
    function neve_child_load_css() {
    wp_enqueue_style( ‘neve-child-style’, trailingslashit( get_stylesheet_directory_uri() ) . ‘style.css’, array( ‘neve-style’ ), NEVE_VERSION );
    }
    endif;
    add_action( ‘wp_enqueue_scripts’, ‘neve_child_load_css’, 20 );

    // Create Weekly Content Post Type
    function cptui_register_my_cpts_weekly() {

    /**
    * Post Type: Weekly Posts.
    */

    $labels = [
    “name” => __( “Weekly Posts”, “neve” ),
    “singular_name” => __( “Weekly Post”, “neve” ),
    ];

    $args = [
    “label” => __( “Weekly Posts”, “neve” ),
    “labels” => $labels,
    “description” => “”,
    “public” => true,
    “publicly_queryable” => true,
    “show_ui” => true,
    “show_in_rest” => true,
    “rest_base” => “”,
    “rest_controller_class” => “WP_REST_Posts_Controller”,
    “has_archive” => true,
    “show_in_menu” => true,
    “show_in_nav_menus” => true,
    “delete_with_user” => false,
    “exclude_from_search” => false,
    “capability_type” => “post”,
    “map_meta_cap” => true,
    “hierarchical” => false,
    “rewrite” => [ “slug” => “weekly”, “with_front” => true ],
    “query_var” => true,
    “supports” => [ “title”, “editor”, “thumbnail” ],
    “taxonomies” => [ “category” ],
    ];

    register_post_type( “weekly”, $args );
    }

    add_action( ‘init’, ‘cptui_register_my_cpts_weekly’ );

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Alrighty, this is some useful information.

    Looks like whoever was building this out originally was using CPTUI as a code generator. Definitely something we don’t fight. It keeps things portable in case someone wants to no longer use our plugin, but need to keep the post type settings.

    Setting Archives to true would make it so you see all the posts in “weekly”, in order by date, latest to oldest. Just like you’d see with the standard blog page. That would be seen at https://songtherapeutics.com/weekly/ but if you set it back to false, then that’d explain why it redirected me to https://songtherapeutics.com/weekly-content/ which appears to be a page. I would need to be able to see more code to better and more cohesively answer the other questions. However it does look like it stands that there’s a fair amount of customization occurring still.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Any changes here?

    Thread Starter swtyndall

    (@swtyndall)

    Hi Michael,

    Thank you so much for your help with this! I’m really impressed. I did want to move forward with fixing this but my client is going with some local tech help and doesn’t want my help anymore. Sorry about not getting back to you sooner!!!

    Best of luck with everything!!

    Steve

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    No worries, I just hope the client gets things to where they need for their website 🙂

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘CPT not registered with CPT UI’ is closed to new replies.