2023-03-04, 04:27:57
(2023-03-04, 03:18:01)tuxy Wrote:Code:<?php
$citySlug = '_parent_'.$data_index->url; // use the url from the city.php (parent)
$result = return_i18n_search_results($citySlug, $words=null, $first=0, $max=9999, $order=null, $lang=null);
?>
I don't know, it is GS related, but when a parent-page (city) has hyphen '-' in the url, by example:
../provincie/antwerpen/heist-op-den-berg/
It does not show the locations (child-pages).
When edit the city-page slug in dashboard to heistopdenberg (without '-'):
../provincie/antwerpen/heistopdenberg/
Then shows the locations correct.
Is there a way allow the '-' character in the search-plugin?
In the search plugin all non-word-characters are translated to "_" (compare data/other/i18n_tag_index.txt). Try
Code:
$citySlug = '_parent_'.preg_replace("/\W+/","_",$data_index->url);
$result = return_i18n_search_results($citySlug, null, 0, 9999)
BTW: the assignments within the function call serve no functionality except assigning the value to a variable, too, i.e. after the function call variable $max is set to 9999.
PHP8 supports named parameters, thus you should be able to write
Code:
$result = return_i18n_search_results(tags: $citySlug, max: 9999)