Forums

[resolved] Can an override to classes.php be made at the template level? (3 posts)

  1. 3vil3mpir3
    Member
    Posted 3 years ago #

    I'd like to make a slight change to start_el, but I would rather not modify the stock file if I can help it. Is it possible to make a modification to a function in classes.php as can be done with other functions with remove_filter and add_filter?

    Thanks much!

  2. 3vil3mpir3
    Member
    Posted 3 years ago #

    To be a little more descriptive of what I'm trying to accomplish:

    I'd like to modify the output of wp_list_pages to include a javascript onclick command on the <li> but I can't seem to get the unique url for each <a> that wp_list_pages is generating.

    essentially, it should look like this:
    <li class="page_item current_page_item" onclick="location.href=' the page url';" style="cursor:pointer;"><a href=" the page url">The page</a>

    I've tried to use get_page_link($page->ID), but it returns the same post url for each instance (rather than a page url).

    As such, I've turned to modifying the start_el entry in classes.php, but I'd rather not make this modification each time I install WP or update it. Is there a way to override the start_el function local to the template? Am I thinking about this the wrong way?

    Any ideas?

  3. 3vil3mpir3
    Member
    Posted 3 years ago #

    Well, the goal of making an onclick event was circumnavigated by adding some css and a background image to the <a> tag like so:

    #topnav a{
    font-weight:bold;
    font-size:18px;
    width:191px;
    height:55px;
    display:block;
    text-decoration:none;
    }
    
    #topnav a:link, a:visited{
    color:#000000;
    background-color:transparent;
    background-image:url(<?php bloginfo('template_directory');?>/images/home-primary_nav.jpg);
    }
    
    #topnav a:hover, a:active{
    color:#ffffff;
    background-color:#000000;
    background-image:none;
    }

    Therefore . . . no need to alter anything. Case closed for this I suppose, but it really would be nice to know if I can alter the start_el in the template's functions.php document. Thoughts?

Topic Closed

This topic has been closed to new replies.

About this Topic