• Hello everyone,

    I’m trying to use WBPA on page to display attachments of a subpage.
    I have a magazine page where the page current issue is the parent page, the issue itself (eg. N°1/2015) is a subpage. I attached several files to my subpage and want to show these attachments on the parent page.

    I am using the following (not working) code for my parent page template:

    <?php
    
    $attachments = array(
    	'post_type' => 'attachment',
    	'post_parent' => 23,
    	'numberposts' => -1
    	);
    $attachments = get_posts($args);
    if ($attachments) {
    		echo wpba_attachment_list( array(
    			'open_new_window'      => true,
    			'show_icon'            => true,
    			'icon_size'           => array( 48, 48 ),
    			'no_attachments_msg'   => 'null',
    
    		) );
    	}
    ?>

    Does anybode have an idea why the code above does not work?

    The plugin itself is a great piece of coding! And works like a charm on regular pages. ??

    Thanks a lot!

    https://www.ads-software.com/plugins/wp-better-attachments/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author dholloran

    (@dholloran)

    Greetings,

    It seems like it should work however you shouldn’t have to do the first query. The wpba_attachment_list function will take care of that for you. I would also check if the first query is returning anything looks right but might as well check. If that doesn’t work let me know.

    Thanks,
    Dan

    Thread Starter cpohl

    (@cpohl)

    Hey,

    using the wpba_attachment_list itself it wont’t work.
    I used the following code:

    <?php
    		echo wpba_attachment_list( array(
    			'open_new_window'      => true,
    			'show_icon'            => true,
    			'icon_size'           => array( 48, 48 ),
    			'no_attachments_msg'   => 'null',
    		) );
    ?>

    Replies “Sorry, no attachments exist.”
    If I am using wordpress get_posts function it works:

    <?php
    $args = array(
    	'post_type' => 'attachment',
    	'post_parent' => $page->ID,
    	'numberposts' => -1,
    	);
    $attachments = get_posts($args);
    if ($attachments) {
    	foreach ($attachments as $attachment) {
    		echo the_attachment_link($attachment->ID, false);
    	}
    }
    ?>

    :/

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Using WPBA with Subpages’ is closed to new replies.