Overwriting default Wordpress function with my own in functions.php

Discussion in 'PHP' started by rochow, Feb 25, 2009.

  1. #1
    I've read some very poorly written posts, none of which worked.

    function get_next_posts_link( $label = 'Next Page »', $max_page = 0 ) {
     global $paged, $wp_query;
    
     if ( !$max_page ) {
      $max_page = $wp_query->max_num_pages;
     }
    
     if ( !$paged )
      $paged = 1;
    
     $nextpage = intval($paged) + 1;
    
     if ( !is_single() && ( empty($paged) || $nextpage <= $max_page) ) {
      $attr = apply_filters( 'next_posts_link_attributes', '' );
      return '<a href="'.next_posts($max_page, false )."\" $attr id=\"next-page\"><img src=\"/images/next.png\" alt=\"next\" /></a>";
     }
    }
    Code (markup):
    This is my function, the only thing that is different is that it's an image instead of text (and has an ID for styling). I want to put this function in the themes function files and have WP use this function, not the default one. How do I do this?
     
    rochow, Feb 25, 2009 IP
  2. HQ Content

    HQ Content Peon

    Messages:
    290
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    For each theme that you'd like to replace the default functions.php file, you simply upload your customized file (it should be named functions.php) to each theme folder in your WordPress install.

    In your hosting control panel, assuming that you upload via a web interface, you should have the option of whether to overwrite existing files with the same name as the new ones you upload.

    You need to select that option and then upload.

    If you are uploading via FTP, you only need to drag the files from your desktop and drop them into the designated folder(s) in your hosting account.
     
    HQ Content, Feb 25, 2009 IP
  3. rochow

    rochow Notable Member

    Messages:
    3,991
    Likes Received:
    245
    Best Answers:
    0
    Trophy Points:
    240
    #3
    You have misunderstood - I want Wordpress to use this function instead of it's own default function. I already have a functions.php.
     
    rochow, Feb 25, 2009 IP