Yes. Just a program example for in a page template. I did not test it but it should work.
<?php
// See if wppa is active
if ( function_exists( 'wppa_albums' ) {
// The name of the expected album must be known or the number ( id ).
// Assume we know the name and the name is in $alb_nam
// See if album with name $alb_nam exists
$alb_id = wppa_get_album_id_by_name( $alb_nam, 'return_dups' );
if ( ! $alb_id ) { // NOT Found!
// Create one
$alb_id = wppa_create_album_entry( array( 'name' => $alb_nam ) );
}
// Found a non-empty result
if ( $alb_id ) {
if ( wppa_is_int( $alb_id ) ) { // Found a single
// Show album content. Note Check box in Table II-D18 to diaplay empty album content
echo do_shortcode( '[wppa type="thumbs" album="' . $alb_id . '"][/wppa]' );
}
else { // Found multiple matches, i.e an enumeration of album numbers like: '2.12.45'
// Do anything you want with the data or just display the covers of all matches
echo do_shortcode( '[wppa type="cover" album="' . $alb_id . '"][/wppa]' );
}
}
else {
echo 'Could not find or create album '.$alb_nam;
}
}
?>
Thread Starter
ktecho
(@ktecho)
Thanks a lot for the ultra-fast reply. Not all plugins do that…
Will report if it works ok.
Additionally you can supply a lot of extra info when the album is created. examples:
$alb_id = wppa_create_album_entry( array(
'name' => $alb_nam, // The name of the album
'description' => 'This album is auto-created.',
'a_parent' => '-1', // Album parent = '--- separate ---'
'owner' => 'admin', // in stead of the current user
'cats' => ',Mycat1,Mycat2,', // Note the surrounding comma's
) );
The full list with defaults is:
'id' => '0',
'name' => __( 'New Album', 'wp-photo-album-plus' ),
'description' => '',
'a_order' => '0',
'main_photo' => wppa_opt( 'main_photo' ),
'a_parent' => wppa_opt( 'default_parent' ),
'p_order_by' => '0',
'cover_linktype' => wppa_opt( 'default_album_linktype' ),
'cover_linkpage' => '0',
'owner' => wppa_get_user(),
'timestamp' => time(),
'modified' => time(),
'upload_limit' => wppa_opt( 'upload_limit_count' ).'/'.wppa_opt( 'upload_limit_time' ),
'alt_thumbsize' => '0',
'default_tags' => '',
'cover_type' => '',
'suba_order_by' => '',
'views' => '0',
'cats' => '',
'scheduledtm' => '',
'crypt' => wppa_get_unique_album_crypt()
Use carefully!
Thread Starter
ktecho
(@ktecho)
I’ve marked it as resolved, as I can create albums programmatically this way.
Thanks Jacob.