WordPress.org

Forums

[resolved] Parse error: syntax error, unexpected ' (7 posts)

  1. Swagata Das
    Member
    Posted 1 year ago #

    Greetings all, currently making a theme when testing it, getting an error Parse error: syntax error, unexpected '<' in C:\wamp\www\wordpress\wp-content\themes\wppro\header.php on line 25. But on line 25 I have <?php wp_head(); ?>. Why I'm getting this error? Isn't the correct use of wp_head?

  2. cubecolour
    ɹoʇɐɹǝpoɯ
    Posted 1 year ago #

    What do you have on the previous line?

  3. Swagata Das
    Member
    Posted 1 year ago #

    [ Moderator note: please wrap code in backticks or use the code button. Do not use blockquote it doesn't work. ]

    <!DOCTYPE html>
    <html <?php language_attributes(); ?>>
      <head>
        <meta charset="<?php bloginfo( 'charset' ); ?>" />
        <title><?php bloginfo( 'name' ); ?><?php wp_title(); ?></title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta name="description" content="">
        <meta name="author" content="">
    
    <?php
    function wppro_script_enqueuer() {
    	//first we register the styles
    	wp_register_style( 'bootstrap', get_stylesheet_directory_uri().'/assets/css/bootstrap.css');
    	wp_register_style( 'bootstrap-responsive', get_stylesheet_directory_uri().'/assets/css/bootstrap-responsive.css');
    	wp_register_style( 'docs', get_stylesheet_directory_uri().'/assets/css/docs.css');
    	wp_register_style( 'prettify', get_stylesheet_directory_uri().'/assets/js/google-code-prettify/prettify.css');
        //now we enqueue them
        wp_enqueue_style( 'bootstrap' );
        wp_enqueue_style( 'bootstrap-responsive' );
        wp_enqueue_style( 'docs' );
        wp_enqueue_style( 'prettify' );
    }
    add_action( 'wp_enqueue_scripts', 'wppro_script_enqueuer');
    
    <?php wp_head(); ?>
      </head>
    
      <body <?php body_class(); ?> data-spy="scroll" data-target=".bs-docs-sidebar">
  4. cubecolour
    ɹoʇɐɹǝpoɯ
    Posted 1 year ago #

    Try adding a new line after

    add_action( 'wp_enqueue_scripts', 'wppro_script_enqueuer');

    containing

    ?>
  5. Swagata Das
    Member
    Posted 1 year ago #

    Thanks, it worked. Do I need to add a space after get_stylesheet_directory_uri() and before .'/my/directory/style.css?

  6. cubecolour
    ɹoʇɐɹǝpoɯ
    Posted 1 year ago #

    No, it is not necessary, but I prefer to add a space before & after the . (string concatenation operator) to make the code easier to read

  7. Swagata Das
    Member
    Posted 1 year ago #

    Thanks for your help. Merry christmas.

Topic Closed

This topic has been closed to new replies.

About this Topic