• Hi all
    Can anyone help me with this.
    I’m wanting to list in the title of the Archive page the ‘single category’ and the ‘sister category’ simlar to the URL:

    URL
    http://domain.co.uk/category/under-9s/match-reports

    TITLE TO READ
    Archives for Under 9’s Match Reports
    OR
    Archives for Match Reports ~ Under 9’s

    there is already single_cat_title in archive.php
    Is it possible to get the category it nests under

    Thanks in advance

Viewing 3 replies - 1 through 3 (of 3 total)
  • The function below will return ‘Under 9s, Match Reports’ when passed the URL you gave.

    <?php
       function cats_from_url ($url) {
         $parts = explode('category/',$url);
         $cat_string = $parts[1];
         // Change dashes to spaces
         $cat_string = str_replace('-', ' ', $cat_string);
         // Drop trailing slash, if any
         $cat_string = preg_replace('#/$#','',$cat_string);
         // Change remaining slashes to comma-space
         $cat_string = preg_replace('#/#', ', ', $cat_string);
         // Uppercase words
         $cat_string = ucwords($cat_string);
         return $cat_string;
       }
    ?>
    Thread Starter devil7

    (@devil7)

    Thanks vtxyzzy, that didn’t work, unless i did something wrong, thanks for the reply though!!

    What did it do? It worked as I explained when I tested it.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Listing ‘Sister’ category’ is closed to new replies.