Forum Replies Created

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter ianworksword

    (@ianworksword)

    I am glad there is now a plugin for this. Much easier than smacking my head against the desk. Thanks moshu for making the connection.

    Thread Starter ianworksword

    (@ianworksword)

    For what it is worth i figured it out. Here is where i inserted the code into the widget.php file:

    <?php echo $before_widget; ?>
    		<?php echo $before_title . $title . $after_title; ?>
    		<ul>
    			<?php /* NEW CODE HERE*/ echo '<li><a href="https://www.yahoo.com">Home</a></li>'; /* END NEW CODE*/ echo $out; ?>
    		</ul>
    	<?php echo $after_widget; ?>

    This at the end of the wp_pages_widget function, and just before the wp_widget_pages_control section of that function. (If that is the right thing to call it.) So there is the solution (at least in my case). Thank you so much for your help. It would not have been possible otherwise.

    Thread Starter ianworksword

    (@ianworksword)

    Dave: This does indeed place a home link. My functions are a little different probably because of the theme I am using. Here is what my code says, starting from the same place you were talking about. I marked where I put in the new code as /** New Line **/:

    function wp_widget_pages( $args ) {
    	extract( $args );
    	$options = get_option( 'widget_pages' );
    
    	$title = empty( $options['title'] ) ? __( 'Pages' ) : $options['title'];
    	$sortby = empty( $options['sortby'] ) ? 'menu_order' : $options['sortby'];
    	$exclude = empty( $options['exclude'] ) ? '' : '&exclude=' . $options['exclude'];
    
    	if ( $sortby == 'menu_order' ) {
    		$sortby = 'menu_order, post_title';
    	}
    /** NEW LINE **/ echo '<li><a href="https://www.yahoo.com">Home</a></li>';
    
    	$out = wp_list_pages('title_li=&echo=0&sort_column=' . $sortby . $exclude );
    
    	if ( !empty( $out ) ) {
    ?>
    	<?php echo $before_widget; ?>
    		<?php echo $before_title . $title . $after_title; ?>
    		<ul>
    			<?php echo $out; ?>
    		</ul>
    	<?php echo $after_widget; ?>
    <?php
    	}
    }

    HOWEVER, this places it not actually in the list….. well it places it in the widget, but not at the top of the unordered list. I tried placing the code right in with the the variable that calls wp_list_pages (i.e. this line:

    $out = wp_list_pages('title_li=&echo=0&sort_column=' . $sortby . $exclude );

    But i couldn’t get it to work. Looking at the code above, is there another recommendation that you have for how to make the home link part of the list? You can see an example of how it isn’t quite working here: https://sandiandneil.com.s20901.gridserver.com/

    Double thank you’s for all of your help thus far. I can tell that I am almost there. (The function widget_pages_control) is the next function, for whatever that is worth).

    – ian

    Thread Starter ianworksword

    (@ianworksword)

    Thanks dave. But you’re not suggesting adding this into the widget.php file somehow right? As it stands, I want the home page to be in the same list as the pages (which your code would do). Normally I could just hard code this into the sidebar. But with widgets enabled, the widgets will replace all of the code that would be in the sidebar.php file. How do I get this to work with the pages widget do you think? (I imagine that there is a simple way to put this in the widget. I did some experimenting, but um… well ‘parsed the code’ i think is the right term, and it didn’t work.) Again, I know enough to try things and not mess anything up, but not enough to solve this without days of experimenting and learning (which someone else can probably solve in a second). Thank you very much for your help thus far.

    Thread Starter ianworksword

    (@ianworksword)

    Yea, i thought about just keeping the href and img links the same; i.e. the site works. I knew that this was the simplest (i.e. still works fine and doesn’t take up more of my time) solution, but assumed that i was doing something wrong, and that maybe there was something sort of not elegant about it (though nothing wrong in principle).

    Well i’m glad to hear that it ‘isn’t’ easily fixable, and not even necessary. I really appreaciate your response. Thanks for your help.

Viewing 5 replies - 1 through 5 (of 5 total)