Support » Plugins » wp_list_pages filter Plugin Trouble

  • Resolved wmrom


    I’m working on a function which will insert ‘first item’ and ‘last item’ into the class attributes of the first and last list-item elements returned by the wp_list_pages() function. This is what I wrote to do it:

    function onw_first_and_last($the_string) {
      $class_position = stripos($the_string,'page_item');
      $string1 = substr($the_string,0,$class_position);
      $string2 = substr($the_string,$class_position);
      $string1 .= 'first_item ';
      $the_string = $string1.$string2;
      $last_class_position = strripos($the_string,'page_item');
      $string3 = substr($the_string,0,$last_class_position);
      $string4 = substr($the_string,$last_class_position);
      $string3 .= 'last_item ';
      $the_string = $string3.$string4;
      return $the_string;

    Then I add it to the ‘wp_list_pages’ filter hook. I have other plugins hooking onto ‘wp_list_pages’ and they work just fine. But whenever I activate this plugin, I get an internal server error on the front end of my website (the wp-admin directory, etc. all works fine). Does anybody have any idea what the problem is?

Viewing 1 replies (of 1 total)
  • Never mind. I just added it into the plugin which was already working.
    I also changed the code to

    $position_first_class=stripos($string,'<li class="');
      $position_first_class += 11;
      $replacement_insert='<li class="first_item ';
      $string_1 = substr($string,0,$position_first_class);
      $string_1 = str_ireplace('<li class="',$replacement_insert,$string_1);
      $string_2 = substr($string,$position_first_class);
      $string = $string_1.$string_2;
      $position_last_class=strripos($string,'<li class="');
      $replacement_insert_2 = '<li class="last_item ';
      $string_3 = substr($string,0,$position_last_class);
      $string_4 = substr($string,$position_last_class);
      $string_4 = str_ireplace('<li class="',$replacement_insert_2,$string_4);
      $string = $string_3.$string_4;

    It works now. Weird…

Viewing 1 replies (of 1 total)
  • The topic ‘wp_list_pages filter Plugin Trouble’ is closed to new replies.