Current-Page Bugfix

Mit diesem Plugin ist es möglich, den WordPress Bug zu umgehen, dass eine Seite die als Beitragsseite genutzt wird, nicht die CSS-Klasse current_page_item bekommt. Zusätzlich gibt das Plugin dem obersten Menüpunkt der aktuellen Auswahl ein current_page_parent mit.

Der genau Bug wurde von mir bereits im Blog beschrieben.

Die Nutzung des Plugins ist denkbar einfach:

  • Plugin downloaden und extrahieren
  • Ordern in wp-plugins hochladen
  • Plugin aktivieren
  • Im Theme an entsprechender Stelle wp_list_pages() mit list_pages_bugfix() ersetzen.

English summary: This plugin allows you to fix a wordpress bug. If you choose a page as your welcome page and another page for your posts, wordpress doesn’t give the css-class current_page_item to the post-page if selected. Any other page get this css-class. Download the plugin and upload it into your wp-plugins directory. After activating it, you can replace wp_list_pages() with list_pages_bugfix() and you don’t have this problem any more.

History:

  • 30. Januar 2008: Version 1.2.1
    * Blog bekommt nun bei einem 404er kein current_page_item mehr
  • 26. Januar 2008: Version 1.2
    * behebt mehrere kleine Bugs
    * fügt dem obersten Menüpunkt der aktuellen Auswahl ein current_page_parent hinzu.
  • 9. Januar 2008: Release der Version 1.0
Tags: , ,

20 Gedanken zu “Current-Page Bugfix

  1. Pingback: Thomas Lippert » Blog Archive » Neues Plugin: Current-Page Bugfix

  2. Hey Walter,

    Today I present the new version which does exactly that: It gives the top menu point a current_page_parent class. I developed nearly the same functionality for my own project. Today I take your name for the class and put it into the existing function. Here you have the version 1.2. Give me a report if you have problems.

    Thomas

  3. Hi Walter,

    sorry that you have to wait a few days. Today there is an update for this plugin. It does not give current_page_item to the blog page when accessing a 404 page any more.

    The other one (accessing a search) is right in my opinion. The search only searches in blog items, so it is the current_page_item, isn’t it? You are invited to give me your arguments.

    Thomas

  4. This plugin works perfectly on my localhost test site, but when I try to apply it on my live site I get the error message:

    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/.vamp/spencyb/spencerbeggs.com/wordpress/wp-content/plugins/currentpagefix/currentpagefix.php

    But I only get this on my index page. Any ideas?

    I’m using WordPress 2.3.3.

  5. Sorry, I thought it was linked to my name in the comments. It’s spencerbeggs.com. I turned the bugfix on. You can get to the index at spencerbeggs.com/clips. Thanks so much for your help.

  6. In case anyone else is experiencing this problem, here is an interim fix is it:

    In currentpagefix.php:

    Change: $ergebnis = mysql_fetch_array($anfrage);
    To: $ergebnis = @mysql_fetch_array($anfrage);

    The error will still exist, but it won’t print out. Thomas said he knows what is going wrong and will look into it when he has time.

    Thanks for your help, Thomas.

  7. one more bugfix in make_cssclass:
    replace: $searchstr = ‘page-item-’.$id;
    with: $searchstr = ‘page-item-’.$id.’ ‘;

    and one more space a bit below:
    $pages = $teile[0].$searchstr.’ ‘.$string[$mode].’ ‘.$teile[1];

    I have home page with id=5 and another page with id=58. explode() splitted “page-item-58″ by “page-item-5″ and most of menu item disappear.

  8. ups, previous one falied in “blog” section
    here is the one that works (somebody, who know PHP – please rewrite this ugly piece of code ;)

    function make_cssclass($id,$pages,$mode = 0){
    $string[0] = ‘current_page_item’;
    $string[1] = ‘current_page_parent’;

    $char = ‘ ‘;
    $searchstr = ‘page-item-’.$id.’ ‘;
    $teile = explode($searchstr,$pages);
    if (count($teile) < 2)
    {
    $searchstr = ‘page-item-’.$id;
    $char = ‘”‘;
    $teile = explode($searchstr.’”‘,$pages);
    }

    $pages = $teile[0].$searchstr.’ ‘.$string[$mode].$char.$teile[1];
    return $pages;
    }

  9. This almost works in 2.6.2 though it tends to drop the remaining menu within the following (li). I’ve tried to implement a few of these fixes in the comments and none work with 2.6.2. Is there any chance for an update as WordPress still hasn’t fixed this issue.

  10. My apologies, this does work fine in 2.6.2. Only if the Options > Reading Post page is set. The problem still persists if the site has several pages where the user could post.

  11. Pingback: Current-Page Bugfix » Thomas Lippert « Wordpress Wiki WP

Hinterlasse eine Antwort

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind markiert *

Du kannst folgende HTML-Tags benutzen: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>