Title: Initial code for functions
Last modified: September 29, 2021

---

# Initial code for functions

 *  Resolved [woodypad](https://wordpress.org/support/users/woodypad/)
 * (@woodypad)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/initial-code-for-functions/)
 * Hello,
    to insert some code as if it were in the functions file, do you have 
   to insert an initial code? how do you do for the css?
 * Because I moved a code that I had in the functions file into code snippet and
   it doesn’t work anymore.

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

 *  Plugin Author [Shea Bunge](https://wordpress.org/support/users/bungeshea/)
 * (@bungeshea)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/initial-code-for-functions/#post-14949901)
 * Can you give an example of the code snippet? Most functions code should just 
   work out of the box, but sometime there’s some adjustment necessary.
 *  Thread Starter [woodypad](https://wordpress.org/support/users/woodypad/)
 * (@woodypad)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/initial-code-for-functions/#post-14950137)
 * Hello,
    thank you for answering. there he is
 *     ```
       add_filter('the_category_list',function ($categories){
           $main_cat = v_primary_category( get_post()->ID );
           if ( $main_cat ) {
               return [get_category($main_cat)];
           }
           if ( ! empty( $categories ) ) {
               return [$categories[0]];
           }
           return $categories;
       });
       ```
   
 * Thank you

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

The topic ‘Initial code for functions’ is closed to new replies.

 * ![](https://ps.w.org/code-snippets/assets/icon.svg?rev=2148878)
 * [Code Snippets](https://wordpress.org/plugins/code-snippets/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/code-snippets/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/code-snippets/)
 * [Active Topics](https://wordpress.org/support/plugin/code-snippets/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/code-snippets/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/code-snippets/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [woodypad](https://wordpress.org/support/users/woodypad/)
 * Last activity: [4 years, 8 months ago](https://wordpress.org/support/topic/initial-code-for-functions/#post-14950137)
 * Status: resolved