• Resolved Marosh

    (@marosvojtko)


    Hello, Im using premium version of your plugin.
    Please can You help me write PHP function which deletes the line from description field that contains specific word. I need to remove (from descriprtion field) the line containing the picture. So I need simple function which will look for “<img” text and than it will delete whole line where “<img” text appears.
    Is that possible please?
    Thank You.

    Example of descritpion:

    description text
    description text
    description text
    description text <img src="/uploads/5/products/7b010876d856c916b87ad0b9378a4f64.jpg" />
    description text
    description text
    description text
    • This topic was modified 5 years, 7 months ago by Marosh.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author WP All Import

    (@wpallimport)

    Hi @marosvojtko

    I need to remove (from descriprtion field) the line containing the picture. So I need simple function which will look for “<img” text and than it will delete whole line where “<img” text appears. Is that possible please?

    Yes, this would be possible with a custom PHP function: https://www.wpallimport.com/documentation/developers/execute-php/. Here is an example function that you can modify as needed:

    function my_parse_content( $content ) {
    	$content = explode( PHP_EOL, $content );
    	foreach ( $content as $key => $value ) {
    		if ( strpos( $value, '<img src=' ) ) {
    			unset( $content[ $key ] );
    		}
    	}
    	return implode( PHP_EOL, $content );
    }
    Thread Starter Marosh

    (@marosvojtko)

    Thank You

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Delete the line that contains specific word’ is closed to new replies.