WordPress.org

Ready to get started?Download WordPress

Forums

Attachments
[resolved] Unable to see Attachments on Custom Post Type (2 posts)

  1. snakespan
    Member
    Posted 1 year ago #

    I'm trying to get the attachments plugin for custom post types, but since attachments has updated, I can't get it to show.

    define( 'ATTACHMENTS_LEGACY', true ); // force the legacy version of Attachments

    I've defined LEGACY to use the old version of attachments (as I know for sure it worked in version 1), but it now only shows for Post and Page types, and not my custom post type of 'Property'.

    This is my code in single-property.php

    <?php
    if( function_exists( 'attachments_get_attachments' ) ){
    $attachments = attachments_get_attachments();
    $total_attachments = count( $attachments );
    if( $total_attachments ) :
    for( $i=0; $i<$total_attachments; $i++ ) : ?>
    <img src="<?php echo $attachments[$i]['location']; ?>" title="<?php echo $attachments[$i]['title']; ?>" />
    <?php endfor; ?>

    <?php endif; ?>
    <?php } ?>

    I've tried creating a custom instance here too - http://wordpress.org/extend/plugins/attachments/other_notes/ but I get a syntax error on this line:

    $fields => array(

    syntax error on T_DOUBLE_ARROW

    Here is the website in question - http://www.james-hayward.com/property/gloucester-road/ (normally the attachments appear on the right of any property page).

    I've looked at the documentation but can't figure it out, so any help would be appreciated.

  2. Jonathan Christopher
    Member
    Plugin Author

    Posted 1 year ago #

    Where did you add that constant, to wp-config.php? If so, please make sure it's added to the top of the file, not the bottom.

    The documentation is for version 3+ so please disregard it if using the legacy version. That syntax error was resolved about a week or so ago.

    $fields => array(

    should be

    $fields = array(

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic