• Resolved paolocappuccini

    (@paolocappuccini)


    In some cases plugin fail to recognized custom post types and sidebar is not replaced.

    i had to change the following code in class-custom-sidebars-replacer.php

    // 1 |== Single posts/pages ——————————————–
    if ( is_single() ) {
    $post_type = get_post_type();

    in:

    // 1 |== Single posts/pages ——————————————–
    if ( is_single() ) {
    $post = get_post();
    $post_type = WP_Post::get_instance( $post->ID )->post_type;

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hey @paolocappuccini,

    Hope you’re well.

    I want to replicate the issue, so can you tell me how did you create custom post types? With plugin, theme or custom coding. And also if can you give me exact instructions (or codes if you create with custom coding) it would be great.

    Cheers,
    Oguz

    Thread Starter paolocappuccini

    (@paolocappuccini)

    Hi Oguz, thanks for reply

    I’m using the plugin Custom Sidebars and i wanted to apply replacing rule to my custom post type “knowledgebase” but the rule is not applied without the code modification that i showen in my previous message.
    Debugging your code i noticed that the line of code “$post_type = get_post_type();” return wrong post_type (it defaults to “page”).
    I don’t know if it is wordpress bug or wrong use of wordpress api but i am sure that my post is of type “knowledgebase”.

    Checking wordpress documentation i can see that “get_post_type” is intended to be called by passing as first argument the post itself, unless you want to fallback in some default cases.

    Hey @paolocappuccini,

    Hope you’re well.

    I understand the situation but I don’t understand how did you create that “knowledgebase” custom post type. When I create custom post type and assign the sidebar to it, it works well for every time. So I can’t replicate it.

    That’s why I am asking that can you explain me how did you create custom post type? Or are you using any plugin for that?

    Cheers,
    Oguz

    Thread Starter paolocappuccini

    (@paolocappuccini)

    I use pressapps knowledge plugin. it uses custom post type and i wanted to use custom sidebar aside its articles.

    Thread Starter paolocappuccini

    (@paolocappuccini)

    what i wanted to say that u probably need a fix (the one i did works fine) to work with custom types created by other plugins

    Hey @paolocappuccini,

    Hope you’re well.

    Okay, looks like the plugin you use is paid plugin, so I can’t test. But I asked the problem to our developers, once I have more information I will update this thread. By the way, if you can replicate from any other plugin that I can test, I would happy to hear that.

    Cheers,
    Oguz

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

The topic ‘custom post types are not always recognized’ is closed to new replies.