Kindy assist. my line 44, I do not see the error. I know it may be a comma, fullstop or a bracket that I can't see/


Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' in /home/content/55/8319155/html/wp-content/themes/WK_theme/functions.php on line 44

************function.php*******

<?php

// Add RSS links to <head> section
automatic_feed_links();


// Load jQuery
if ( !is_admin() ) {
   wp_deregister_script('jquery');
   wp_register_script('jquery', ("http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"), false);
   wp_enqueue_script('jquery');
}


// Clean up the <head>
function removeHeadLinks() {
	remove_action('wp_head', 'rsd_link');
	remove_action('wp_head', 'wlwmanifest_link');
}
add_action('init', 'removeHeadLinks');
remove_action('wp_head', 'wp_generator');



// Declare sidebar widget zone
if (function_exists('register_sidebar')) {
	register_sidebar(array(
		'name' => 'Sidebar Widgets',
		'id'   => 'sidebar-widgets',
		'description'   => 'These are widgets for the sidebar.',
		'before_widget' => '<div id="%1$s" class="widget %2$s">',
		'after_widget'  => '</div>',
		'before_title'  => '<h2>',
		'after_title'   => '</h2>'
	));
}

// Main Navigation Menu
	if ( function_exists( 'register_nav_menus' ) ) 
	{
    		register_nav_menus(
    		array(
			'main_nav' => 'Main Navigation Menu',	
	));
    }


//allow thumbnails
if ( function_exists( 'add_theme_support' ) ) { 
  add_theme_support( 'post-thumbnails' ); 
}


// get featured image title
  function WK_img_title() {
    global $post;
    $wk_thumbnail_id = get_post_thumbnail_id($post->ID);
    $wk_thumbnail_image = get_posts(array('p' => $wk_thumbnail_id, 'post_type' => 'attachment', 'post_status' => 'any'));
    if ($wk_thumbnail_image && isset($wk_thumbnail_image[0])) {
      return $wk_thumbnail_image[0]->post_title;
    }
  }

// get featured image caption
  function WK_img_caption() {
    global $post;
    $wk_thumbnail_id = get_post_thumbnail_id($post->ID);
    $wk_thumbnail_image = get_posts(array('p' => $wk_thumbnail_id, 'post_type' => 'attachment', 'post_status' => 'any'));
    if ($wk_thumbnail_image && isset($wk_thumbnail_image[0])) {
      return $wk_thumbnail_image[0]->post_excerpt;
    }
  }


// Custom Post Type for Galleries

add_action('init', 'register_gallery', 1); // Set priority to avoid plugin conflicts

function register_gallery() { // A unique name for our function

$labels = array( // Used in the WordPress admin
    'name' => _x('Galleries', 'post type general name'),
    'singular_name' => _x('Gallery', 'post type singular name'),
    'add_new' => _x('Add New', 'Gallery Item'),
    'add_new_item' => __('Add New Gallery Item'),
    'edit_item' => __('Edit Gallery Item'),
    'new_item' => __('New Gallery Item'),
    'view_item' => __('View Gallery Item'),
    'search_items' => __('Search Galleries'),
    'not_found' =>  __('Nothing found'),
    'not_found_in_trash' => __('Nothing found in Trash')
);

$args = array(
	'labels' => $labels, // Set above
	'public' => true, // Make it publicly accessible
	'query_var' => true,
	'publicly_queryable' => true,
	'hierarchical' => false, // No parents and children here
	'menu_position' => 5, // Appear right below "Posts"
	'has_archive' => 'galleries', // Activate the archive
	'supports' => array('title','editor','excerpt','thumbnail','author',)
);
register_post_type( 'gallery', $args ); // Create the post type, use options above 
}

$labels_topics = array(
    'name' => _x( 'Gallery Category', 'taxonomy general name' ),
    'singular_name' => _x( 'Gallery Category', 'taxonomy singular name' ),
    'search_items' =>  __( 'Search Gallery Categories' ),
    'all_items' => __( 'All Gallery Categories' ),
    'parent_item' => __( 'Parent Gallery Category' ),
    'parent_item_colon' => __( 'Parent Gallery Category:' ),
    'edit_item' => __( 'Edit Gallery Category' ),
    'update_item' => __( 'Update Gallery Category' ),
    'add_new_item' => __( 'Add New Gallery Category' ),
    'new_item_name' => __( 'New Gallery Category Name' ),
);

register_taxonomy(
    'gallery_category', // The name of the custom taxonomy
    array( 'gallery' ), // Associate it with our custom post type
    array(
        'hierarchical' => true,
        'rewrite' => array(
            'slug' => 'gallery_category', // Use "topic" instead of "topics" in permalinks
            'hierarchical' => true // Allows sub-topics to appear in permalinks
            ),
        'labels' => $labels_gallery_category
        )
    ); 


//custom columns display for back-end 
add_action("manage_posts_custom_column", "my_custom_columns", 5, 2);
add_filter("manage_edit-gallery_columns", "my_gallery_columns");

function my_gallery_columns($columns) //this function display the columns headings
{
	$columns = array(
		"cb" => "<input type=\"checkbox\" />",
		"title" => "Title",
		"thumbnail" => "Photo",
		"date" => "Date"

);
return $columns;
}

function my_custom_columns($column, $id)
{
	if($column == "thumbnail"){
        echo the_post_thumbnail(array(60,60));
    }
}

?>

    I think it's due to the comma at the end of the preceding line (array definition).

      Thanks alot! It worked! These codes are very funny! Just a comma!!!! and I have sweated the whole day!!! What's the best PHP debugging software out there I can be using? Thanks!

        I get no parse errors when I lint the code you posted.

        Edit: And apparently I need to refresh after a meeting to see new posts first.

          Derokorian;11041077 wrote:

          I get no parse errors when I lint the code you posted.

          Same here - code from original post showed no syntax errors according to my local install of PHP version 5.5.6.

          @: Out of curiosity, which version of PHP are you using?

            There was a time when you could not have that trailing comma, but I don't recall whether allowing it was a PHP 5 thing, or a PHP 5.x[.y] thing?

              Allowing the trailing comma was introduced in PHP4. Notice that the definition of the [font=monospace]$args[/font] array down in [font=monospace]register_gallery[/font] also has a trailing comma.

              There is something else dodgy about line 43, though: I think there were some non-breaking spaces on the end of the line there.

                Write a Reply...