• Resolved Amirhosein Davatgari

    (@amirhoseindavat)


    hey there, I need to bulk rename the tab’s I’ve been created before at once!
    need to change the Tab Title field for 90% of the created tab, how it possible?
    the Tab Title’s data is stored on wp databases ? if yes, I think it possible with a SQL query, if no, plz give me a way to fix this, I need it strongly
    Regards

    The page I need help with: [log in to see the link]

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Contributor yikesitskevin

    (@yikesitskevin)

    Hi @amirhoseindavat,

    Please do not update your tabs via a SQL query. The tab data is saved as a serialized array and manual search and replaces in the DB will break your tabs.

    There’s no way to rename a tab without using a custom PHP script that loops through all of your products, fetches the tabs, updates the tab titles, and saves the tab again.

    This isn’t very hard to write if you’re familiar with PHP. The tabs array is saved in yikes_woo_products_tabs.

    e.g.
    $tabs = get_post_meta( $product_id, 'yikes_woo_products_tabs', true );

    Are you familiar with PHP? If I write a script, will you be able to apply it?

    Let me know.

    Cheers,
    Kevin.

    Thread Starter Amirhosein Davatgari

    (@amirhoseindavat)

    tnx for the quick answer
    I know PHP’s basics, if the script can apply in function.php or etc like this, yea I can apply it, but if another way is required, if you help me a little I can apply it
    Regards

    Plugin Contributor yikesitskevin

    (@yikesitskevin)

    Are all of your tabs custom tabs? What titles do you need to rename?

    Plugin Contributor yikesitskevin

    (@yikesitskevin)

    I am assuming all of the tabs you want to rename are custom tabs. Here is a script that will update any tab named “Old Tab Title!” to “New Tab Title!”. Obviously you’ll have to change these names to match what your old and new titles are.

    add_action( 'admin_init', 'manual_cpt_rename' );
    
    // Manually rename tabs.
    function manual_cpt_rename() {
    
    	if ( ! isset( $_GET['manual_cpt_rename'] ) ) {
    		return;
    	}
    
    	// Fetch all products.
    	$products = new WP_Query(
    		array(
    			'post_status'    => 'any',
    			'post_type'      => 'product',
    			'fields'         => 'ids',
    			'posts_per_page' => '-1',
    		)
    	);
    
    	if ( $products->have_posts() ) {
    
    		foreach ( $products->posts as $product ) {
    
    			$tabs = get_post_meta( $product, 'yikes_woo_products_tabs', true );
    
    			if ( ! empty( $tabs ) ) {
    
    				foreach ( $tabs as $key => &$tab ) {
    
    					if ( $tab['title'] === 'Old Tab Title!' ) {
    						$tab['title'] = 'New Tab Title!';
    					}
    				}
    
    				update_post_meta( $product, 'yikes_woo_products_tabs', $tabs );
    			}
    		}
    	}
    }

    Add this snippet to functions.php and then go to your WordPress admin and change the URL to {yoursite.com}/wp-admin/?manual_cpt_rename in order to fire off the snippet. (i.e. add the ?manual_cpt_rename to your admin URL).

    Hope that makes sense.

    Cheers,
    Kevin.

    Thread Starter Amirhosein Davatgari

    (@amirhoseindavat)

    no, I removed the tag tab for the product page, but I have the other default tabs
    descriptionand additional_information,
    my site’s language is Persian so the tabs titles are Persian
    my tab name is “????? ????????”
    I want to change all of the “????? ????????” to “????? ???? ????”
    if you have a problem with this, I had to rename the tabs manually

    Thread Starter Amirhosein Davatgari

    (@amirhoseindavat)

    tnx buddy, tnx for your awesome plugin
    good luck
    Regards

    Plugin Contributor yikesitskevin

    (@yikesitskevin)

    Let me know if that snippet worked for you!

    Thread Starter Amirhosein Davatgari

    (@amirhoseindavat)

    yea, it works
    thank you, you saved my site ??

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Bulk rename’ is closed to new replies.