Grow your CSS skills. Land your dream job.

Parsing error in WP functions.php -localhost

  • # November 26, 2010 at 5:55 pm

    I’m testing a WP site that I’m developing locally using XAMPP.

    I’ edited functions.php to include a function that grabs images that are attached in a post. After I edit the file, and navigate to a page that calls the function I get this:
    Parse error: syntax error, unexpected $end in C:xampplitehtdocswordpresswp-contentthemesIncrediline Themefunctions.php on line 105

    Any ideas? I’ve integrated this function before on a live site with no problems at all. The code that I use to call the function is inside the loop:

    < ?php nerdy_get_images('t1x1','4','3','full',"$post->ID",'1','attachment-image','div','small-thumb') ?>

    And here’s my function.php :

    < ?php
    // Add the ability to use post thumbnails if it isn't already enabled.
    // Not required. Use only of you want to have more than the large,
    // medium or thumbnail options WP uses by default.

    if ( function_exists( 'add_image_size' ) ) add_theme_support( 'post-thumbnails' );

    // Add custom thumbnail sizes to your theme. These sizes will be auto-generated
    // by the media manager when adding images to it on a new post.
    if ( function_exists( 'add_image_size' ) ) {
    add_image_size( 't1x1', 145, 200, true );
    add_image_size( 't2x1', 307, 200, true );
    add_image_size( 't2x2', 307, 417, true );
    }

    ///////////////////////////////////////////////
    //
    // Start Nerdy.Biz WP Custom Galley Function
    //
    //////////////////////////////////////////////

    function nerdy_get_images($size = 'thumbnail', $limit = '0', $offset = '0', $big = 'large', $post_id = '$post->ID', $link = '1', $img_class = 'attachment-image', $wrapper = 'div', $wrapper_class = 'attachment-image-wrapper') {
    global $post;

    $images = get_children( array('post_parent' => $post_id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID') );

    if ($images) {

    $num_of_images = count($images);

    if ($offset > 0) : $start = $offset--; else : $start = 0; endif;
    if ($limit > 0) : $stop = $limit+$start; else : $stop = $num_of_images; endif;

    $i = 0;
    foreach ($images as $attachment_id => $image) {
    if ($start < = $i and $i < $stop) {
    $img_title = $image->post_title; // title.
    $img_description = $image->post_content; // description.
    $img_caption = $image->post_excerpt; // caption.
    //$img_page = get_permalink($image->ID); // The link to the attachment page.
    $img_alt = get_post_meta($attachment_id, '_wp_attachment_image_alt', true);
    if ($img_alt == '') {
    $img_alt = $img_title;
    }
    if ($big == 'large') {
    $big_array = image_downsize( $image->ID, $big );
    $img_url = $big_array[0]; // large.
    } else {
    $img_url = wp_get_attachment_url($image->ID); // url of the full size image.
    }

    // FIXED to account for non-existant thumb sizes.
    $preview_array = image_downsize( $image->ID, $size );
    if ($preview_array[3] != 'true') {
    $preview_array = image_downsize( $image->ID, 'thumbnail' );
    $img_preview = $preview_array[0]; // thumbnail or medium image to use for preview.
    $img_width = $preview_array[1];
    $img_height = $preview_array[2];
    } else {
    $img_preview = $preview_array[0]; // thumbnail or medium image to use for preview.
    $img_width = $preview_array[1];
    $img_height = $preview_array[2];
    }
    // End FIXED to account for non-existant thumb sizes.

    ///////////////////////////////////////////////////////////
    // This is where you'd create your custom image/link/whatever tag using the variables above.
    // This is an example of a basic image tag using this method.
    ?>
    < ?php if ($wrapper != '0') : ?>
    < class="< ?php echo $wrapper_class; ?>">
    < ?php endif; ?>
    < ?php if ($link == '1') : ?>
    " title="< ?php echo $img_title; ?>">
    < ?php endif; ?>
    < ?php echo $img_alt; ?>
    < ?php if ($link == '1') : ?>

    < ?php endif; ?>
    < ?php if ($img_caption != '') : ?>
    < ?php echo $img_caption; ?>

    < ?php endif; ?>
    < ?php if ($img_description != '') : ?>
    < ?php echo $img_description; ?>

    < ?php endif; ?>
    < ?php if ($wrapper != '0') : ?>
    >
    < ?php endif; ?>
    < ?
    // End custom image tag. Do not edit below here.
    ///////////////////////////////////////////////////////////

    }
    $i++;
    }

    }
    }

    ///////////////////////////////////////////////
    //
    // End Nerdy.Biz WP Custom Galley Function
    //
    //////////////////////////////////////////////
    ?>

    Thanks!

    # November 26, 2010 at 6:14 pm

    Solved!

    There was a short tag

    (< ? instead of 

    in the function.php file that was not liked!

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".