Monday, February 29, 2016

wp - setup_postdata($post2) wont work

It has to be

global $post;
$post=$post2;
setup_postdata($post);

LINK:

https://codex.wordpress.org/Function_Reference/setup_postdata

otherwise, you might get wrong link in the_excerpt and so on


ALSO:

If it redirects to the other version of the post, make sure you check .htaccess and any of the REDIRECT plugins.

Also, it can be caused by the non-unique slug!

ALSO:

In some configurations (probably  due to what is being translated by WPML ), if get_field("name", post_id) fails, the original content can  be obtained by:

$sitepress->switch_lang($orig_lang);
get_field("name", $orig_lang_id);
$sitepress->swithc_lang($cur_lang);


No comments:

Post a Comment

Ubuntu 12.04, 14.04, 16.04 - auto start an app or script before login

To run a command or application at startup, even before the user has logged in, you can use this file: /etc/rc.local The commands entered...