WordPress.org

Forums

Custom Post Widget
[resolved] Fatal error: Cannot redeclare my_content_block_post_type_init() (11 posts)

  1. wgrivera
    Member
    Posted 1 year ago #

    Updated my plugin to latest version and I'm getting Fatal error: Cannot redeclare my_content_block_post_type_init() in plugins/custom-post-widget/post-widget.php on line 113

    http://wordpress.org/plugins/custom-post-widget/

  2. Johan van der Wijk
    Member
    Plugin Author

    Posted 1 year ago #

    Hi wgrivera,

    It seems that you have another plugin installed which uses the same function name to create the custom post type. Could you try deactivating all other plugins and then activating them one-by-one to see which plugin is causing the conflict?

  3. wgrivera
    Member
    Posted 1 year ago #

    Hi Johan,

    I deactivated all plugins and only installed custom post type but I'm still getting the same error. I'm on a multisite installation but the version I had installed was working fine on it.

  4. Johan van der Wijk
    Member
    Plugin Author

    Posted 1 year ago #

    Mmm, that is very strange indeed. I am also using the plugin on several multisite installations without any problems and I have not seen this error.

    It might be that the custom post widget plugin is not only in the regular plugins folder, but also in the mu-plugins folder, as it seems it is trying create the content block custom post type twice.

    If the above is not the case you could try renaming the function my_content_block_post_type_init on lines 111 and 113 of the file post-widget.php as it might be that somewhere in your theme the same function name is being used.

  5. wgrivera
    Member
    Posted 1 year ago #

    Renamed the function and it just gave me the error Fatal error: Cannot redeclare my_content_block_post_type_init2()

    If I comment it it will give me an error with the next function. Looks like there is another instance of the plugin. But I can't find it.

  6. Johan van der Wijk
    Member
    Plugin Author

    Posted 1 year ago #

    Did you manage to fix this? You could try using ftp to download all the files from your webserver and then search for the duplicate function.

  7. wgrivera
    Member
    Posted 1 year ago #

    I haven't been able to fix it but I will try searching for a duplicate and let you know.

  8. wgrivera
    Member
    Posted 1 year ago #

    I searched my entire folder for my_content_block_post_type_init() and only one file came with a result and is post-widget.php inside the plugin folder. I guess there is no duplicate.

  9. wgrivera
    Member
    Posted 1 year ago #

    I just found out that the plugin is working on the main site and is only sub-sites that are giving me the error.

  10. Johan van der Wijk
    Member
    Plugin Author

    Posted 1 year ago #

    The Custom Post Widget is compatible with multi-site installations, so that should not be the issue.

    The fact that it is working on the main site, might point to some issues with the multi-site install. Are you using sub-domains, sub-folders or separate domains for the sub-sites?

  11. John Sundberg
    Member
    Posted 1 year ago #

    I'm using version 2.4.5, and I was running into this issue on some sites but not others. The solution I came up with was to change the

    require( 'post-widget.php' );

    in line 41 of custom-post-widget.php to

    require_once( 'post-widget.php' );

    Great plugin, by the way!
    John

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Custom Post Widget
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags

No tags yet.