[Closed] Can't get icl_object_id to return original post ID for custom posts

Home Support English Support [Closed] Can't get icl_object_id to return original post ID for custom posts

Tagged: 

This topic contains 5 replies, has 2 voices, and was last updated by  Roni 1 year, 1 month ago. The support staff assigned to this topic is Harshad.

Viewing 6 posts - 1 through 6 (of 6 total)
Author Posts
Author Posts
April 1, 2012 at 4:26 pm #54202

Roni

Hi using this function, tried many variations, but simply can't get the original language post attachments for translated languages.

function apartment_photos () {
    echo '<div id="page_featured">';
    echo the_post_thumbnail( 'fsingle' );
    echo '</div><div class="clear"></div>';
    echo '<div id="single_gallery" class="marquee">';
	$type = get_post_type($id);
	$oID = icl_object_id($id, $type, false, 'en'); // tried here to set post type to my custom post type 'listing' or 'post', neither works
	$attachments = get_children(array('post_parent' => $oID, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order_by' => 'menu_order')); 
// when using actual original language post id as 33 instead of $oID, all works fine...
	            if ( ! is_array($attachments) ) continue;
	            $count = count($attachments);
 
	            foreach ($attachments as $ats) {
	            $atmeta = wp_get_attachment_metadata($ats->ID);
	            $atsrc = wp_get_attachment_image_src($ats->ID, array(125,80));
    echo '<a href="'. $ats->guid .'" class="lytebox" data-lyte-options="group:gal" data-title="'.get_the_title($ats->ID).'" 

title="'.get_the_title($ats->ID).'">';
    echo '<img src="'.$atsrc[0].'" width="125" height="80" title="'.get_the_title($ats->ID).'" alt="'.get_the_title($ats->ID).'">';
    echo '</a>';
}
    echo '</div>';
    echo '<div class="clear"></div>';
}

If I set post id manually, everything works fine…

April 2, 2012 at 4:16 am #54225

Harshad

Did you give a try setting language information button?

Please go to wpml -> support -> click on the troubleshooting link at the bottom of the page.

On the troubleshooting page click on the set language information button.

April 3, 2012 at 1:38 pm #54447

Roni

No luck… Tried that already…

April 4, 2012 at 8:02 pm #54655

Roni

I would really need help with this one… Still no luck. Just can't get translated posts to show original post gallery images…

April 5, 2012 at 3:50 am #54675

Harshad

Dear Roni,

Any chance if you could send me your ftp and wp-admin details along with the filename which has the code of original language post attachments to my email address?

I will further investigate on your issue(s).

April 6, 2012 at 2:56 pm #54864

Roni

Thank you Harshad for great support :-)

Viewing 6 posts - 1 through 6 (of 6 total)

The topic ‘[Closed] Can't get icl_object_id to return original post ID for custom posts’ is closed to new replies.