• Plugin Contributor Chris Dillon

    (@cdillon27)


    To change the slug from “testimonial” to “review”, for example, add this to your theme’s functions.php:

    /**
     * Customize the Strong Testimonials plugin.
     *
     * Change "testimonial" to "review".
     */
    function change_strong_permastruct() {
    // permalink structure
      add_permastruct( 'wpm-testimonial', "review/%wpm-testimonial%", array( 'slug' => 'review' ) );
    }
    add_action( 'init', 'change_strong_permastruct' );

    You may need to flush the rewrite rules by going to Settings > Permalinks and simply clicking “Save Changes”.

    To change the various labels in admin, add this too:

    /**
     * Customize the Strong Testimonials plugin.
     *
     * Change labels containing the word "testimonial".
     */
    function change_strong_labels() {
      global $wp_post_types;
    
      // get currentlabels
      $labels = &$wp_post_types['wpm-testimonial']->labels;
    
      // ================
      // original values:
      // ================
      // 'name'                  => _x( 'Testimonials', 'post type general name', 'strong-testimonials' ),
      // 'singular_name'         => _x( 'Testimonial', 'post type singular name', 'strong-testimonials' ),
      // 'add_new'               => __( 'Add New', 'strong-testimonials' ),
      // 'add_new_item'          => __( 'Add New Testimonial', 'strong-testimonials' ),
      // 'edit_item'             => __( 'Edit Testimonial', 'strong-testimonials' ),
      // 'new_item'              => __( 'New Testimonial', 'strong-testimonials' ),
      // 'all_items'             => __( 'All Testimonials', 'strong-testimonials' ),
      // 'view_item'             => __( 'View Testimonial', 'strong-testimonials' ) ,
      // 'search_items'          => __( 'Search Testimonials', 'strong-testimonials' ),
      // 'not_found'             => __( 'Nothing Found', 'strong-testimonials' ),
      // 'not_found_in_trash'    => __( 'Nothing found in Trash', 'strong-testimonials' ),
      // 'parent_item_colon'     => ''
    
      // ==================================
      // uncomment and change as necessary:
      // ==================================
      $labels->name               = 'Reviews';
      $labels->singular_name      = 'Review';
      // $labels->add_new            = 'add_new';
      // $labels->add_new_item       = 'add_new';
      // $labels->edit_item          = 'edit_item';
      // $labels->new_item           = 'name';
      // $labels->view_item          = 'view_item';
      // $labels->search_items       = 'search_items';
      // $labels->not_found          = 'not_found';
      // $labels->not_found_in_trash = 'not_found_in_trash';
    }
    add_action( 'wp_loaded', 'change_strong_labels' );

    I plan on adding this option to the plugin itself.

    By the way, if you’re using a free or premium theme and you’re worried about theme updates overwriting this customization, now’s the time to use a child theme! I would be glad to help you with that.

    https://www.ads-software.com/plugins/strong-testimonials/

  • The topic ‘How to change the slug’ is closed to new replies.