I've done something wrong. I set up a custom post type,

I've done something wrong. I set up a custom post type, with taxonomy(ies) which I don't really understand, and custom fields. I did a sample post and put it into it's category (taxonomy?) , and added that to the menu ("cars"). Cars showed up, but no post (on the live side). So I put it into a regular Wordpress category, and it still didn't show up (on the live side). Not sure what I've done wrong. Right now, the post is using the regular WP cats. The post is http://www.hybridcarsinformation.net/vehicle/2015-audi-q5-hybrid/. The custom category is "cars" but it is in "hybrid cars" right now (regular WP category) .

Also, would it be possible to not have "vehicle" in the url?

  • Vinod Dalvi

    Hi CBO,

    I hope you are well today and thank you for your question.

    Have you created the custom post type/taxonomies using any plugin like CustomPress or developing custom code?

    Would you mind if I logged in to your site and did some troubleshooting? This might help get to the bottom of this faster. If this is ok, just grant me temporary admin access to your site by clicking "Grant Access" button in the WPMU DEV Dashboard Settings as described on the following page and reply on this thread after granting it?

    https://premium.wpmudev.org/manuals/wpmu-dev-dashboard-enabling-staff-login/

    Also, would it be possible to not have "vehicle" in the url?

    The "vehicle" is a custom post type therefore it's displaying in the URL.

    You can remove the "vehicle" post type slug from the URL by using the attached small plugin containing the following code.

    /**
     * Remove the slug from published post permalinks. Only affect our CPT though.
     */
    
    function gp_remove_cpt_slug( $post_link, $post, $leavename ) {
    
        if ( 'vehicle' != $post->post_type || 'publish' != $post->post_status ) {
            return $post_link;
        }
    
        $post_link = str_replace( '/' . $post->post_type . '/', '/', $post_link );
    
        return $post_link;
    }
    add_filter( 'post_type_link', 'gp_remove_cpt_slug', 10, 3 );
    
    /**
     * Have WordPress match postname to any of our public post types (page, post, race)
     * All of our public post types can have /post-name/ as the slug, so they better be unique across all posts
     * By default, core only accounts for posts and pages where the slug is /post-name/
     */
    function gp_parse_request_trick( $query ) {
    
        // Only noop the main query
        if ( ! $query->is_main_query() )
            return;
    
        // Only noop our very specific rewrite rule match
        if ( 2 != count( $query->query ) || ! isset( $query->query['page'] ) ) {
            return;
        }
    
        // 'name' will be set if post permalinks are just post_name, otherwise the page rule will match
        if ( ! empty( $query->query['name'] ) ) {
            $query->set( 'post_type', array( 'post', 'vehicle', 'page' ) );
        }
    }
    add_action( 'pre_get_posts', 'gp_parse_request_trick' );

    Best Regards,
    Vinod Dalvi

  • Vinod Dalvi

    Hi CBO,

    Thank you for granting the support staff access.

    I can see you have granted the support staff access on the site techopolis.org but you have shared the post from the site http://www.hybridcarsinformation.net so please tell me on which site exactly you are facing this issue and as you have many sub sites on your mulsisite techopolis.org so also tell me the specific site URL.

    Also make sure that the issue is reproduced on the site by adding appropriate menu ( Cars ) so that i can troubleshoot it.

    Regards,
    Vinod Dalvi

  • CBO

    Vinod, the car site is a subsite of techopolis. I can't give permission for a subsite, can I? If so, please let me know!

    Anyway, I deleted the custom category "cars" and added "hybrid cars", and changed the post to be in that new category, and now the one post shows up. But, the top of the page says "Archive" instead of the name of the category, like the other category pages do. So I must still have something wrong.

    You know, what I'd really like to have, if it's possible, is a page that is just like a regular post, except that it shows certain custom fields. Would that be just a simple template page, or is that what Custompress is making, only with all the extra stuff, like it's own area and all?

  • Vinod Dalvi

    Hi CBO,

    Vinod, the car site is a subsite of techopolis. I can't give permission for a subsite, can I? If so, please let me know!

    If grant the permission of main site in the multisite network then we can access its subsites also so now i could access that site using the URL http://techopolis.org/hybridcarsinformation

    Anyway, I deleted the custom category "cars" and added "hybrid cars", and changed the post to be in that new category, and now the one post shows up. But, the top of the page says "Archive" instead of the name of the category, like the other category pages do. So I must still have something wrong.

    I have just tested it on your site techopolis.org/hybridcarsinformation temporary assigning "hybrid cars" category to post and it's displaying "Hybrid Cars" at the top of the category page as shown in the attached screenshot.

    Please advise.

    You know, what I'd really like to have, if it's possible, is a page that is just like a regular post, except that it shows certain custom fields. Would that be just a simple template page, or is that what Custompress is making, only with all the extra stuff, like it's own area and all?

    You can just use the following custompress shortcodes in the post content to display all or certain custom fields.

    To display all custom fields:

    [custom_fields_block]

    To display certain custom fields:

    [ct id="_ct_selectbox_4cf582bd61fa4" property="title"]
    [ct id="_ct_selectbox_4cf582bd61fa4" property="description"]
    [ct id="_ct_selectbox_4cf582bd61fa4" property="value"]

    Find more information about it in the custom fields section of custompress as shown in the attached screenshot.

    If you want to display it on any other custom page template file then use the code like following.

    To display all custom fields:

    <?php echo do_shortcode('[custom_fields_block]'); ?>

    To display certain custom fields:

    <?php echo do_shortcode('[ct id=&quot;_ct_selectbox_4cf582bd61fa4&quot; property=&quot;title&quot;]'); ?>
    <?php echo do_shortcode('[ct id=&quot;_ct_selectbox_4cf582bd61fa4&quot; property=&quot;description&quot;]'); ?>
    <?php echo do_shortcode('[ct id=&quot;_ct_selectbox_4cf582bd61fa4&quot; property=&quot;value&quot;]'); ?>

    Regards,
    Vinod Dalvi

  • CBO

    The category "Hybrid Cars" is in 2 places - the regular WP categories, and also under Vehicles - the custom category. Which one did you use? Because I still have the custom post showing under Archives. Here is my screenshot, I got it from pressing "Hybrid Cars" in the Nav Bar (with arrow). I tried it on 2 computers to make sure it wasn't cached on this one, also on my phone. They all say archives.

    Also, I understand adding the shortcodes, but I want to style the info, and don't want to have to add it manually to every post. So would I make a copy of single.php and add the php code to it? If so, where would I store that (in which folder)?

    Thanks for your help!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.