hi there,
for anyone working amfphp and wordpress
i just made this two functions that may be usefull
Get Image: get the url of the first image attachment of a given post
/**
* Gets the first image of a post of the requiered type
* .
* .
* @param $ID post_id
* @param $type thumbnail, medium, large, full
* @returns File URL or Null
*/
function get_image($ID, $type) {
if($ID!='')
{
if ( $images = get_children(array(
'post_parent' => $ID,
'post_type' => 'attachment',
'numberposts' => 1,
'post_mime_type' => 'image')))
{
foreach( $images as $image ) {
// $attachmenturl=wp_get_attachment_url($image->ID);
$attachmentimage=wp_get_attachment_image_src( $image->ID, $type );
// $imagelink=get_permalink($image->post_parent);
}
}
return $attachmentimage[0];
}
else
{
return;
}
}
Get Pages Menu: returns all pages with order different than 0, and their subpages (this function uses EzSQL, so you have to adapt the queryes it if you don’t use this adapter)
/**
* Gets all the pages that don't have page_order=0, so you can exclude pages from this menu assigning 0 to them.
* This function can be expanded to get a third level of submenus.
* .
* .
* @returns Array of objects, the first item is the first level, the others are second levels, all levels are ordered by page_order
*/
public function get_menu() {
$pages = $this->db->get_results(" SELECT ID, post_title, post_name from wp_posts where post_status='publish' AND post_parent='0' AND post_type='page' AND not menu_order='0' ORDER BY menu_order ASC ");
$menu[0] = $pages;
$count = 1;
foreach ( $pages as $page )
{
$subpages = $this->db->get_results(" SELECT ID, post_title, post_name, post_parent from wp_posts where post_status='publish' AND post_parent='".$page->ID."' AND post_type='page' AND not menu_order='0' ORDER BY menu_order ASC");
if ($this->db->num_rows>0)
{
$menu[$count] = $subpages;
$count++;
}
//echo $user->name;
//echo $user->email;
}
return $menu;
}