baxter13
Forum Replies Created
-
Forum: Plugins
In reply to: PopupGallery hack /using the post ID out of loopI’ve figured out the variable for the page ID.
global $wp_query;
$pageid = $wp_query->post->ID;If anyone else is trying something similar, here is the functional code, thanks to help from Andy Stains at Yellowswordfish.com (PopupGallery creator).
If anyone has ideas on how to add headings for each category of parent page on the main Index page, that would be great. I’ll post if I find a solution.
// tag: fg_gallery_index - place an index of links somewhere (i.e. sidebar) - also called from Page tag 'galleryindex'
// -------------------------------------------------------------------------------------------------------------------
function fg_gallery_index($image_class='gallerythumb', $index_style='table', $show=true)
{
global $table_prefix, $wpdb, $wp_query;
$pageid = $wp_query->post->ID;// the code here should retrieve the current page's ID
$parentid = $wp_query->post->post_parent;
// determine the parent page ID
//now load the collection records
// changed to order the gallery by the parent pages and then by the post title
// the where statement limits the index images to the ones whose parent page is the current page
$fg_imagedata = $wpdb->get_results('SELECT ' . $table_prefix . 'gallerypage.ID, ' . $table_prefix . 'gallerypage.gallerypath, ' . $table_prefix . 'gallerypage.indextext, ' . $table_prefix . 'gallerycollection.thumbfile, ' . $table_prefix . 'posts.post_title
FROM ' . $table_prefix . 'gallerypage
LEFT JOIN ' . $table_prefix . 'posts ON ' . $table_prefix . 'gallerypage.ID = ' . $table_prefix . 'posts.ID
LEFT JOIN ' . $table_prefix . 'gallerycollection ON ' . $table_prefix . 'gallerypage.ID = ' . $table_prefix . 'gallerycollection.ID
WHERE ' . $table_prefix . 'gallerycollection.indexfile = 1 AND ' . $table_prefix . 'posts.post_parent = ' . $pageid . ' OR ' . $table_prefix . 'gallerycollection.indexfile = 1 AND ' . $parentid . ' = 0
ORDER BY ' . $table_prefix . 'posts.post_parent, ' . $table_prefix . 'posts.post_title;');