Title: Adding HTML to tables
Last modified: August 21, 2016

---

# Adding HTML to tables

 *  Resolved [Andrew Leonard](https://wordpress.org/support/users/andrewleonard/)
 * (@andrewleonard)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/adding-html-to-tables/)
 * Hi
    If you look at this page: [http://www.andrew-leonard.co.uk/wordpress/ferns-2/growing/spore-exchange/spore-list/](http://www.andrew-leonard.co.uk/wordpress/ferns-2/growing/spore-exchange/spore-list/)
   You will see that the first entry “Acrostichum aureum” has a HTML link to do 
   a Google search. I have put the HTML in the cell. My question is, is there any
   way of arranging for the HTML code to be added to each cell without having to
   put it in myself – rather in the same way that you can add a CSS style to a whole
   row with one command in “Plugin Options”
 * [https://wordpress.org/plugins/tablepress/](https://wordpress.org/plugins/tablepress/)

Viewing 15 replies - 16 through 30 (of 34 total)

[←](https://wordpress.org/support/topic/adding-html-to-tables/?output_format=md)
[1](https://wordpress.org/support/topic/adding-html-to-tables/?output_format=md)
2 [3](https://wordpress.org/support/topic/adding-html-to-tables/page/3/?output_format=md)
[→](https://wordpress.org/support/topic/adding-html-to-tables/page/3/?output_format=md)

 *  Thread Starter [Andrew Leonard](https://wordpress.org/support/users/andrewleonard/)
 * (@andrewleonard)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/adding-html-to-tables/page/2/#post-4970441)
 * Dear Ziya
    Not sure what it is you want to do exactly If you just want to show
   the images, you wrap your urls in html for example <img src=”[http://www.ps4home.com/wp-content/uploads/2013/10/NO-BOX-ART.jpg”/&gt](http://www.ps4home.com/wp-content/uploads/2013/10/NO-BOX-ART.jpg”/&gt);
   You do this in the TablePress cell I have done this here: [http://ebps.org.uk/publications/special-publications](http://ebps.org.uk/publications/special-publications)
   Does this answer your problem? If not then I can explain more about add_filter
 *  [ziyaindia78](https://wordpress.org/support/users/ziyaindia78/)
 * (@ziyaindia78)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/adding-html-to-tables/page/2/#post-4970442)
 * Dear Andrew,
 * Thanks for replying
 * I want same thing that you have done.
 * The only difference is that you have done for a specific column value while I
   want do this for all row values for 2 columns.
 * Thanks,
    Ziya
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/adding-html-to-tables/page/2/#post-4970443)
 * Hi Ziya,
 * then, you’ll just need an “or” in your `if` expression.
 * Can you maybe post the code that you are using now, so that we can debug it? 
   It should be pretty similar to the code from above.
 * Regards,
    Tobias
 *  [ziyaindia78](https://wordpress.org/support/users/ziyaindia78/)
 * (@ziyaindia78)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/adding-html-to-tables/page/2/#post-4970444)
 * I am using following code
 * add_filter( ‘tablepress_cell_content’, ‘Google_Wrap15’, 10, 4 );
    function Google_Wrap15(
   $tablepress_cell_content, $table_id, $row_number, $column_number ) { if ($table_id
   ==1) { if ($column_number==8 or $column_number==9) { $x=strpos($tablepress_cell_content,‘(‘);
   if ($x==0) {$temp=$tablepress_cell_content;} else {$temp=substr($tablepress_cell_content,
   0,$x);} $tablepress_cell_content = ‘<img src=”‘.$tablepress_cell_content.'”/>’;}}
   return $tablepress_cell_content; }
 *  Thread Starter [Andrew Leonard](https://wordpress.org/support/users/andrewleonard/)
 * (@andrewleonard)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/adding-html-to-tables/page/2/#post-4970445)
 * You want to remove these lines:
    $x=strpos($tablepress_cell_content, ‘(‘); if(
   $x==0) {$temp=$tablepress_cell_content;} else {$temp=substr($tablepress_cell_content,
   0,$x);}
 * The it should work
 *  Thread Starter [Andrew Leonard](https://wordpress.org/support/users/andrewleonard/)
 * (@andrewleonard)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/adding-html-to-tables/page/2/#post-4970446)
 * Also I think the line should be:
 * $tablepress_cell_content = “<img src=”.$tablepress_cell_content.”/>”;
 *  [ziyaindia78](https://wordpress.org/support/users/ziyaindia78/)
 * (@ziyaindia78)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/adding-html-to-tables/page/2/#post-4970447)
 * Thanks for your help
 * It’s working on Mozila / Firefox but not working on chrome.
 * URL – [http://www.gamesage.co.uk/?page_id=8](http://www.gamesage.co.uk/?page_id=8)
 *  [ziyaindia78](https://wordpress.org/support/users/ziyaindia78/)
 * (@ziyaindia78)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/adding-html-to-tables/page/2/#post-4970448)
 * I am using following function
 * add_filter( ‘tablepress_cell_content’, ‘Google_Wrap15’, 2, 8 );
    function Google_Wrap15(
   $tablepress_cell_content, $table_id, $row_number, $column_number ) { if ($table_id
   ==1) { if($row_number >= 2) { if ($column_number==8) { $tablepress_cell_content
   = ‘<img width=”50″ height=”50″ src=”‘.$tablepress_cell_content.'”/>’; } else 
   if ($column_number==9){ $includes_images_url = includes_url().’images/buy_now.
   png’; $tablepress_cell_content = ‘[<img width=”72″ height=”32″ src=”‘.$includes_images_url.'”/>](https://wordpress.org/support/topic/adding-html-to-tables/page/2/&apos;.$tablepress_cell_content.&apos;?output_format=md)‘;}}}
   return $tablepress_cell_content; }
 *  Thread Starter [Andrew Leonard](https://wordpress.org/support/users/andrewleonard/)
 * (@andrewleonard)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/adding-html-to-tables/page/2/#post-4970449)
 * Whoa!
    Column 8 is an image so the above code should work but column 9 is a link
   so you need code that looks like this:
 * “;
 * Of course you can put anything in “click here” including a link to an image as
   in <img src=’[http://yourpath/camera.png’&gt](http://yourpath/camera.png’&gt);
 *  Thread Starter [Andrew Leonard](https://wordpress.org/support/users/andrewleonard/)
 * (@andrewleonard)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/adding-html-to-tables/page/2/#post-4970450)
 * It does not work for me in IE, Chrome or Firefox
 *  Thread Starter [Andrew Leonard](https://wordpress.org/support/users/andrewleonard/)
 * (@andrewleonard)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/adding-html-to-tables/page/2/#post-4970451)
 * Try this – I would copy and paste it from the email
 * add_filter( ‘tablepress_cell_content’, ‘ziyaindia78_table1’, 10, 4 );
    function
   ziyaindia78_table1( $tablepress_cell_content, $table_id, $row_number, $column_number){
   if ($table_id==1) { if($row_number >1) { if ($column_number==8) { $tablepress_cell_content
   = “<img width=’50’ height=’50’ src='”.$tablepress_cell_content.”‘/>”; } else 
   if ($column_number==9){ $tablepress_cell_content = “[click here](https://wordpress.org/support/topic/adding-html-to-tables/page/2/".$tablepress_cell_content."?output_format=md)“;}}}
   return $tablepress_cell_content; }
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/adding-html-to-tables/page/2/#post-4970452)
 * Hi,
 * nice progress here!
 * Please try this, which I reformatted a little bit and where I made the naming
   more consistent:
 *     ```
       add_filter( 'tablepress_cell_content', 'ziya_wrap_images', 10, 4 );
       function ziya_wrap_images( $cell_content, $table_id, $row_number, $column_number ) {
       	if ( '1' == $table_id ) {
       		if ( $row_number > 1 ) {
       			if ( 8 == $column_number ) {
       				$cell_content = '<img width="50" height="50" src="' . esc_url( $cell_content ) . '"/>';
       			} elseif ( 9 == $column_number ) {
       				if ( 'TBA' !== $cell_content ) {
       					$image_url = includes_url() . 'images/buy_now.png';
       					$image_html = '<img width="72" height="32" src="' . esc_url( $image_url ) . '"/>';
       					$cell_content = '<a href="' . esc_url( $cell_content ) . '">' . $image_html . '</a>';
       				}
       			}
       		}
       	}
       	return $cell_content;
       }
       ```
   
 * Note that you’ll have to save the table after making changes to this code (or
   wait 12 hours) to clear the cache.
 * Regards,
    Tobias
 *  [ziyaindia78](https://wordpress.org/support/users/ziyaindia78/)
 * (@ziyaindia78)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/adding-html-to-tables/page/2/#post-4970453)
 * Dear Tobias / Andrew
 * Thanks for all your reply but still images are not displaying on chrome.
 * [http://www.gamesage.co.uk/?page_id=8](http://www.gamesage.co.uk/?page_id=8)
 * Thanks in advance,
    Ziya
 *  [ziyaindia78](https://wordpress.org/support/users/ziyaindia78/)
 * (@ziyaindia78)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/adding-html-to-tables/page/2/#post-4970454)
 * Dear Tobias / Andrew
 * Please check
 * Thanks,
    Ziya
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/adding-html-to-tables/page/2/#post-4970455)
 * Hi Ziya,
 * where have you added this PHP code now? Is it working in other browsers? That
   would be strange, as I can’t see any changes on the page here. Or are you maybe
   using a caching plugin that could be influencing this?
 * Regards,
    Tobias

Viewing 15 replies - 16 through 30 (of 34 total)

[←](https://wordpress.org/support/topic/adding-html-to-tables/?output_format=md)
[1](https://wordpress.org/support/topic/adding-html-to-tables/?output_format=md)
2 [3](https://wordpress.org/support/topic/adding-html-to-tables/page/3/?output_format=md)
[→](https://wordpress.org/support/topic/adding-html-to-tables/page/3/?output_format=md)

The topic ‘Adding HTML to tables’ is closed to new replies.

 * ![](https://ps.w.org/tablepress/assets/icon.svg?rev=3192944)
 * [TablePress - Tables in WordPress made easy](https://wordpress.org/plugins/tablepress/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/tablepress/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/tablepress/)
 * [Active Topics](https://wordpress.org/support/plugin/tablepress/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/tablepress/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/tablepress/reviews/)

 * 34 replies
 * 3 participants
 * Last reply from: [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * Last activity: [11 years, 3 months ago](https://wordpress.org/support/topic/adding-html-to-tables/page/3/#post-4970459)
 * Status: resolved