Help with php for wordpress
Could anyone help me with that php script, I'm very new to php and having troubles with making this code to work
$current = $post->ID;
$parent = $post->post_parent;
$grandparent_get = get_post($parent);
$grandparent = $grandparent_get->post_parent;
if ($root_parent = get_the_title($grandparent) !== $root_parent = get_the_title($current)) {echo ' <a href="get_permalink($grandparent)">get_the_title($grandparent)</a>';}else {echo '<a href="get_permalink($parent)">get_the_titl开发者_Go百科e($parent)</a>';}
The last bit from 'if doesnt work i guess there is some syntax problem
Many thanks,
Variable does not parsed if they are quoted with single quote.
There are many way to parse them but I am posting one of them try below code
echo " <a href=\"get_permalink($grandparent)\">get_the_title($grandparent)</a>";}
else {echo "<a href=\"get_permalink($parent)\">get_the_title($parent)</a>";}
OR
echo '<a href="'.get_permalink($grandparent).'">'.get_the_title($grandparent).'</a>';}
else {echo '<a href="'.get_permalink($parent).'">'.get_the_title($parent).'</a>';}
精彩评论