Title: Adding a Filter with str_replace to functions.php
Last modified: August 19, 2016

---

# Adding a Filter with str_replace to functions.php

 *  [llamaman](https://wordpress.org/support/users/llamaman/)
 * (@llamaman)
 * [17 years ago](https://wordpress.org/support/topic/adding-a-filter-with-str_replace-to-functionsphp/)
 * Hello!
    I am a NOOB when it comes to writing functions for the functions.php 
   file. What I would like to do is to incorporate the “More to the Top” plugin 
   into a theme via the functions.php file.
 * Here is my code that is not working in my functions.php file:
 *     ```
       add_filter( 'the_content', 'moretothetop' );
   
       function moretothetop( $content ) {
       	global $post;
   
       	return str_replace( array( '#more-' . $post->ID . '"', '<span id="more-' . $post->ID . '"></span>' ), array( '"', '' ), $content);
       }
       ```
   
 * Can you help me figure this out?
 * Thanks!

The topic ‘Adding a Filter with str_replace to functions.php’ is closed to new replies.

 * 0 replies
 * 1 participant
 * Last reply from: [llamaman](https://wordpress.org/support/users/llamaman/)
 * Last activity: [17 years ago](https://wordpress.org/support/topic/adding-a-filter-with-str_replace-to-functionsphp/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
