I can use either the php script for a menu

<!-- menu -->
<?php function wpb_custom_new_menu() {
  register_nav_menu('my-custom-menu',__( 'My Custom Menu' ));
add_action( 'init', 'wpb_custom_new_menu' ); ?>

or the post thumbnail script

<!-- post thumbnails -->
<?php add_theme_support('post-thumbnails') ?>

But when I use both under eachother (like the above) then I can't update my custom theme editor anymore. Is there a way to seperate these codes that I don't know of? My php knowledge is 0..

  • I use a custom wordpress theme that i created myself – Bram Werink Apr 29 '20 at 7:01

Your issue is likely with your PHP opening and closing tags (these things: <?php, ?>. If you have an open PHP tag, <?php, and then try to add another one, you will cause a fatal error.

It's important with your PHP files to keep track of your PHP tags so that they're balanced, just like HTML tags need to be. For a standard functions.php file you likely only need a single PHP tag at the very beginning (you shouldn't use a closing PHP tag if it's the end of the file):

function wpb_custom_new_menu() {
    register_nav_menu('my-custom-menu',__( 'My Custom Menu' ));
add_action( 'init', 'wpb_custom_new_menu' );

function wpb_theme_supports() {
add_action( 'after_setup_theme', 'wpb_theme_supports' );    

Note that add_theme_support() needs to be within a function that's hooked on after_setup_theme. Also, don't put HTML comments in your functions file like that. It will always be output and will likely cause headers related errors.

  • I will try this, and the comments I put there for stackexchange but thanks, i noticed that the hard way – Bram Werink Apr 29 '20 at 7:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.