I wanted to create a shortcode so I can "connect" my Coppermine gallery with my Wordpress, sadly I haven't been able to do it
I use this in my posts
[cpg album="533"]
To call this function
function cpg_shortcode( $attr ) {
shortcode_atts(
array(
'album' => 1,
), $attr
);
return $album_id = $attr['album'];
return '<script src="http://linklink.net/cpg/api-posts.php"></script>';
}
add_shortcode( 'cpg', 'cpg_shortcode' );
And this is the script file, which has no errors, it work perfectly fine, but I have to get the album id in it
$query = mysql_query("SELECT * FROM `cpgq7_pictures` WHERE aid=$album_id ORDER BY ctime DESC LIMIT 0 , 3");
echo 'document.write(\'';
if(mysql_num_rows($query) == 0){
echo 'No hay fotos';
} else {
echo '<h6>';
while($row = mysql_fetch_array($query)){
$domain = "http://linklink.net/cpg";
$album_url = "$domain/thumbnails.php?album=$album_id#content";
$album_img = "$domain/albums/".$row['filepath'].'thumb_'.$row['filename'];
echo '<a href="'.$album_url.'" target="_blank"><img src="'.$album_img.'" alt="" /></a>';
}
echo '<a href="'.$album_url.'" target="_blank"><img src="https://i.imgur.com/4wmomUt.png" alt="" /></a></h6>';
}
echo '\');';
When I try to get the album id from the shortcode it doesn't work
Any help is appreciated.