wordpress - Get custom field value but hide first 19 and last 2 characters -


geeks , code gods,

i having issue wordpress code. have added 3 columns dashboard's pages screen.

one of displays custom field 'scode'. scode custom field holds cart66 shortcode adds 'add cart' button page assigned to.

the shortcode looks this:

[add_to_cart item="hd-nl-7010"] 

each page has different shortcode. every shortcode same length, 31 characters long.

however id prefer not show whole shortcode in column, product code *hd-nl-7010* section of code.

is possible hide first 19 , last 2 characters. removing [add_to_cart item=" , "]

below code added function.php add custom columns pages table:

function test_modify_post_table( $column ) {     $column['scode'] = 'product code';     $column['price'] = 'price';     $column['product_image'] = 'image';     return $column; }  add_filter( 'manage_pages_columns', 'test_modify_post_table' );   function test_modify_post_table_row( $column_name, $post_id ) {     $custom_fields = get_post_custom( $post_id );      switch ($column_name) {         case 'scode' :             echo $custom_fields['scode'][0];             break;           case 'price' :             echo '£' . $custom_fields['price'][0];             break;           case 'product_image' :             echo $custom_fields['product_image'][0];             break;          default:     } }  add_filter( 'manage_pages_custom_column', 'test_modify_post_table_row', 10, 2 ); 

thank reading post. appreciated.

p.s. i'm going ask in post know how product_image show image in page column rather image attachment id?

i might misunderstanding, php's substr help? like:

case 'scode' :     echo substr( $custom_fields['scode'][0], 19, 10 );     break; 

for it's worth, think i'd store code (hd-nl-7010) in custom field, rather shortcode code, apply shortcode needed (with do_shortcode).


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -