WordPress.org

Ready to get started?Download WordPress

Forums

PHP syntax error help. New to theme shaping. (4 posts)

  1. Dovahkiin
    Member
    Posted 1 year ago #

    Hey! I'm following a tutorial on ThemeShaper (click link to see the current page I'm on) and I'm experiencing some errors that I have located, but I don't know how to fix them (I'm new to PHP). Can you help me? The syntax errors are on lines 7, 13, 14 and 16 according to my editor. They are direct copy-paste from this tutorial, and I don't know what I can do or replace them with. When I remove this code from the functions.php file, my site is invalid. When I add it, my site is working, but only until the get_page_number is called in the title in my index.php file. Does this make any sense to any of you? I would appreciate your help!

    The syntax errors are located in my functions.php file.

    <?php
    
    // Make theme available for translation
    // Translations can be filed in the /languages/ directory
    load_theme_textdomain( 'customtheme', TEMPLATEPATH . '/languages' );
     
    $locale = get_locale();
    $locale_file = TEMPLATEPATH . "/languages/$locale.php";
    if ( is_readable($locale_file) )
        require_once($locale_file);
     
    // Get the page number
    function get_page_number() {
        if ( get_query_var('paged') ) {
            print ' | ' . __( 'Page ' , 'customtheme') . get_query_var('paged');
        }
    } // end get_page_number

    In my index.php file, the get_page_number is called through this code within my <title></title> tags.:

    <?php
            if ( is_single() ) { single_post_title(); }
            elseif ( is_home() || is_front_page() ) { bloginfo('name'); print ' | '; bloginfo('description'); get_page_number(); }
            elseif ( is_page() ) { single_post_title(''); }
            elseif ( is_search() ) { bloginfo('name'); print ' | Search results for ' . wp_specialchars($s); get_page_number(); }
            elseif ( is_404() ) { bloginfo('name'); print ' | Not Found'; }
            else { bloginfo('name'); wp_title('|'); get_page_number(); }
        ?>

    When I view source my code on my local server, this is what pops up:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US">
    
    <head profile="http://gmpg.org/xfn/11">
        <title>Dovahkiin | Just another WordPress site

    There's probably an easy fix to this ;)

  2. Jose Castaneda
    Member
    Posted 1 year ago #

    Wow that is an old tutorial. Have you read the most recent one?

  3. Dovahkiin
    Member
    Posted 1 year ago #

    Oh, I took Google results for granted... Thanks, I'll look into this new tutorial!

  4. Jose Castaneda
    Member
    Posted 1 year ago #

    No problem! :) They are up to the Archive template so far.

Topic Closed

This topic has been closed to new replies.

About this Topic