Title: Combine code into function
Last modified: August 22, 2016

---

# Combine code into function

 *  Resolved [BGH_](https://wordpress.org/support/users/bgh_/)
 * (@bgh_)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/combine-code-into-function/)
 * Hello, I’m trying to merge the code you gave me previously on another support
   topic, inside the author function of the List category posts plugin.
 * This is the function:
 *     ```
       public function get_author_to_show($single){
           if ($this->params['author'] == 'yes'):
             $lcp_userdata = get_userdata($single->post_author);
             $author_name = $lcp_userdata->display_name;
             if($this->lcp_not_empty('author_posts_link') &&
               $this->params['author_posts_link'] == 'yes'){
               $link = get_author_posts_url($lcp_userdata->ID);
               return "<a href=" . $link . " title='" . $author_name .
                 "'>" . $author_name . "</a>";
             } else {
               return " -  <em>por " . $author_name . "</em>";
             }
           else:
             return null;
           endif;
         }
       ```
   
 * And I’m trying to merge, if that’s the word, inside that function this code:
 *     ```
       <?php $author_name = get_post_meta(get_the_ID(), 'user_submit_name', true);
       				if (!empty($author_name)) echo $author_name; ?>
       ```
   
 * With this i want to show the user submitted post author (not the one auto-assigned)
   on the list of post of a certain category.
 * Can you help me to achieve this? I’m trying to do it by myself, but I’m failing
   to realize how to do it properly :(.
 * Thanks in advance!
 * Best regards.
 * [https://wordpress.org/plugins/user-submitted-posts/](https://wordpress.org/plugins/user-submitted-posts/)

Viewing 1 replies (of 1 total)

 *  Plugin Author [Jeff Starr](https://wordpress.org/support/users/specialk/)
 * (@specialk)
 * [11 years ago](https://wordpress.org/support/topic/combine-code-into-function/#post-5345424)
 * It looks like your theme is doing something specific/custom with the Loop. I 
   would contact your theme developer and ask the best way to add the snippet. That’s
   gonna be your best bet as the theme author knows if there are any other functions
   involved, etc.

Viewing 1 replies (of 1 total)

The topic ‘Combine code into function’ is closed to new replies.

 * ![](https://ps.w.org/user-submitted-posts/assets/icon-256x256.png?rev=2567685)
 * [User Submitted Posts – Enable Users to Submit Posts from the Front End](https://wordpress.org/plugins/user-submitted-posts/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/user-submitted-posts/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/user-submitted-posts/)
 * [Active Topics](https://wordpress.org/support/plugin/user-submitted-posts/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/user-submitted-posts/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/user-submitted-posts/reviews/)

## Tags

 * [author_name](https://wordpress.org/support/topic-tag/author_name/)

 * 1 reply
 * 2 participants
 * Last reply from: [Jeff Starr](https://wordpress.org/support/users/specialk/)
 * Last activity: [11 years ago](https://wordpress.org/support/topic/combine-code-into-function/#post-5345424)
 * Status: resolved