Kako v WordPressu preimenujemo »posts«

WordPress že dolgo ni več le sistem za urejanje vsebin blogov, ampak tudi spletnih strani. V primerih, ko je WordPress namenjen urejanju vsebin spletnih strani pa nam poimenovanje objav »posts« običajno neprimerno. Zato je preimenovanje besede »posts« v novice odlična rešitev.

Primer spodnje kode nam omogoča ravno to, enostavno zamenjavo oz. preimenovanje besede »posts« v poljubno drugo besedo. Vse kar potrebujemo je, da spodnjo kodo prekopiramo v datoteko functions.php.

/*
Plugin Name: Rename Posts to News
Description: Rename built in posts to be called News
Version: 1.0
Author: Scott Cariss @ Philosophy Design
Author URI: http://www.philosophydesign.com
*/

// Not a WordPress context? Stop.
! defined( 'ABSPATH' ) and exit;

 

add_action( 'init', array ( 'chg_Posts_to_News', 'init' ) );
add_action( 'admin_menu', array ( 'chg_Posts_to_News', 'admin_menu' ) );

class chg_Posts_to_News
{
public static function init()
{
global $wp_post_types;
$labels = &$wp_post_types['post']->labels;
$labels->name = 'Corporate News';
$labels->singular_name = 'Corporate News';
$labels->add_new = 'Add Corporate News';
$labels->add_new_item = 'Add Corporate News';
$labels->edit_item = 'Edit Corporate News';
$labels->new_item = 'Corporate News';
$labels->view_item = 'View Corporate News';
$labels->search_items = 'Search Corporate News';
$labels->not_found = 'No corporate news found';
$labels->not_found_in_trash = 'No corporate news found in trash';
$labels->name_admin_bar = 'Corporate News';
}

public static function admin_menu()
{
global $menu;
global $submenu;
$menu[5][0] = 'Corporate News';
$submenu['edit.php'][5][0] = 'Corporate News';
$submenu['edit.php'][10][0] = 'Add Corporate News';
}
}

Vir: https://wordpress.stackexchange.com/questions/49414/change-existing-label-in-the-admin-bar-with-something-else

Komentiraj


*