function getParentID() {
$url = 'http://' . $_SERVER[ 'HTTP_HOST' ] . $_SERVER[ 'REQUEST_URI' ];
$pageID = url_to_postid($url);
$pageID = trim($pageID);
return $pageID;
}
function OrderFieldsQuery($args) {
//->> WORKS WITH HARD-CODED ID'S
$args['post_parent'] = 52;
$args['post_parent'] = getParentID();
// Doesn't work in that way, even function returns same value;
return $args;
}
add_filter('acf/fields/relationship/query', 'OrderFieldsQuery', 10, 1); // add key to filter
** Weiteres Beispiel: **Probleme mit functions.php
global $wp;
$currentUrl = home_url(add_query_arg(array(),$wp->request));
$ID = url_to_postid($currentUrl);
$args['post_parent'] = $ID;
$args['post_parent1'] = 52;
if ($args['post_parent'] === $args['post_parent1'])
$args['equal'] = true;
// Doesn't work in that way, even function returns same value;
return $args;
Output i auf diese bekommen .........:
Array ([post_parent] => 52 [post_parent1] => 52 [gleich] => 1)
So sind sie gleich, aber es funktioniert nur, wenn sie fest codiert sind.
Was gibt 'var_dump (getParentID())' zurück? – Qirel