• Resolved deuts

    (@deuts)


    Apparently, this plugin cannot re-define a function as a snippet item.

    In my functions.php I tried re-defining the function twentysixteen_entry_meta() from the TwentySixteen theme, which is found in inc/template-tags.php, in order to add custom post taxonomies in the entry post meta. The code I had worked well when it was in functions.php, but when I transferred it as snippets of this plugin, it didn’t work.

    Is there a workaround for this, or anything?

    https://www.ads-software.com/plugins/code-snippets/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Shea Bunge

    (@bungeshea)

    Snippet code runs at a different time in the load order than themes, so perhaps that is the issue. Still, it should run before functions.php, so I’ll have to see what might be going wrong.

    Plugin Author Shea Bunge

    (@bungeshea)

    Have you tried a snippet like this?

    if ( ! function_exists( 'twentysixteen_entry_meta' ) ) :
    
    function twentysixteen_entry_meta() {
    	echo 'custom entry meta';
    }
    
    endif;

    I just tested it on my dev site, and it appears to work as expected.

    Thread Starter deuts

    (@deuts)

    But the function already exists in the twentysixteen parent theme, which as I have described is found in inc/template-tags.php.

    Plugin Author Shea Bunge

    (@bungeshea)

    Yes, I know that, and this snippet defines that function before the inc/template-tags.php file is loaded.

    I just put up an online dev site which is running only the Twenty Sixteen theme, the Code Snippets plugin and this snippet – have a look how the entry meta is changed.

    https://dev.bungeshea.com/wp/

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Re-defnining a function’ is closed to new replies.