Forum Replies Created

Viewing 8 replies - 16 through 23 (of 23 total)
  • Since I posted the above two links, I discovered a couple of mistakes. I guess I was just too excited to put up my results. Here’s two new links that should work better:
    https://pastebin.com/W16cxDfY – functions.php
    and
    https://pastebin.com/CGx4aprf – for your WordPress template

    Okay folks, I’ve finally found an answer to this problem. Praise God. Yes, I have been working on it this whole time. It has been, by far, the most frustrating thing I have ever tried to do with WordPress. Here is the fix on how to achieve a clean WordPress menu, using wp_nav_menu without resorting to a custom walker:

    https://pastebin.com/470Q2G9K – place this code in your functions.php file

    https://pastebin.com/u1tNQ8XY – place this code in your theme file where you want the menu to appear

    The above solution doesn’t place line breaks or tabs as nicely as I would like, but aside from that – I’d say it does a nearly perfect job! If anybody has any comments or suggestions, please post a reply – I’d love to keep making this better.

    Thanks.

    I’m still struggling with this. Unfortunately, the solution offered by forbze does not work. It would appear that my custom walker (see above) strips out any custom classes I insert from the backend. I would offer a reward for an answer, but after reading the forum rules, I’ve found that I can’t offer money for a solution to this through these forums. If somebody has already created a custom walker or some other function that pulls this off – I would be very grateful if you would share that with us.

    Also, since I can’t edit the above, I’ll repost some updated specifications for what I’m trying to do. The goal is for the final HTML to look like this:

    [Code moderated as per the Forum Rules. Please use the pastebin]

    Place the following code in your functions.php file and you should be set:

    //Replaces the WordPress URL and Title on the login page
    function custom_login_url () {
        echo bloginfo ('url');
    }
    add_filter ('login_headerurl', 'custom_login_url');
    function custom_login_title () {
        echo bloginfo ('name');
    }
    add_filter ('login_headertitle', 'custom_login_title');

    Here is an updated version of the walker that strips out all of the WordPress mess from the menu code:
    [Code moderated as per the Forum Rules. Please use the pastebin]

    While doing an excellent job of stripping out unnecessary code, this does nothing to add the first and last classes and I’m not 100% pleased with the line breaks and tabs. I’m still searching for that perfect solution. Does anybody out there know what it is?

    I am also very interested in a solution to this. I have been trying almost since the release of WordPress 3.0 to accomplish just this. Why you ask? I’ve already developed an external CSS file that defines various, specific classes for my navigation menu. I want to use this same CSS file across the entire site – some pages of which may be using WordPress and some pages are not. Also, I find that the additional id’s and classes that WordPress throws in there are not necessary for my purposes and just creates superfluous and clunky HTML. Using the single word “active” verses “current-menu-item” is just a personal preference of mine. I have created a walker class that strips a lot of the code, but a solution for cleaning up the the li elements still proves to be annoyingly elusive. Below is my walker that I’ve got so far (placed in the functions.php file):
    [Code moderated as per the Forum Rules. Please use the pastebin]

    And then within the PHP file where the menu should appear, I simply put the following block of code:
    [Code moderated as per the Forum Rules. Please use the pastebin]

    Another option that I found on stackoverflow.com (see here) is to insert the following block of code in your functions.php file:

    add_filter('nav_menu_css_class', 'my_css_attributes_filter', 100, 1);
    add_filter('nav_menu_item_id', 'my_css_attributes_filter', 100, 1);
    add_filter('page_css_class', 'my_css_attributes_filter', 100, 1);
    function my_css_attributes_filter($var) {
      return is_array($var) ? array() : '';
    }

    The above solution is great for stripping out most of the unwanted id’s and classes, but still leaves

    class=””

    on the li element instead of deleting the class altogether. It also failes to remove the

    class=”sub-menu”

    on the ul element of a submenu.

    Whether using a custom walker or some other block of code in the functions.php file, the desired end result is HTML that looks like this:
    [Code moderated as per the Forum Rules. Please use the pastebin]

    If anybody out there can provide some additional insight, modifications to the code above, or some other way of accomplishing this end result, I’m sure there are a lot of people out here in the WordPress community – myself included – that would greatly appreciate it.

    Thread Starter RevelationTravis

    (@revelationtravis)

    Okay, I found a fix for my issue – do not use quotes and do not use commas. The whole shortcode must still be on one line, it cannot be separated into multiple lines. It’s a fix for the most part and the page for this plugin should be updated to reflect the fact that quotes and commas should not be used. A note about the necessity of it all being on a single line should probably also be made.

    What was the function and how is it supposed to appear in order for the author field to stop showing up blank when the PHP code <?php the_author(); ?> is used?

Viewing 8 replies - 16 through 23 (of 23 total)