Title: Html code after third widget
Last modified: June 24, 2017

---

# Html code after third widget

 *  [autox420](https://wordpress.org/support/users/autox420/)
 * (@autox420)
 * [8 years, 9 months ago](https://wordpress.org/support/topic/html-code-after-third-widget/)
 * _[ Moderator note: [moved to Fixing WordPress](https://wordpress.org/support/topic/before-posting-in-everything-wordpress/?view=all).]_
 * Where can i put html code so it apears after third widget?
    No extra widget like”
   html widget” i need the html code in .php file.
 * Widget 1 Widget 2 Widget 3 [ html code here ] Widget 4 Widget 5

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [svetlin1984](https://wordpress.org/support/users/svetlin1984/)
 * (@svetlin1984)
 * [8 years, 9 months ago](https://wordpress.org/support/topic/html-code-after-third-widget/#post-9257783)
 * Where appears those widgets, in header, footer or sidebar? Can you send a screenshot
   and explain what exactly you want to do.
 *  Thread Starter [autox420](https://wordpress.org/support/users/autox420/)
 * (@autox420)
 * [8 years, 9 months ago](https://wordpress.org/support/topic/html-code-after-third-widget/#post-9257794)
 * Website: [http://mixmaking.we2host.lt/wordpress/](http://mixmaking.we2host.lt/wordpress/)
 * Widget 1 Widget 2 Widget 3
 * Html code here
 * Widget 4 Widget 5 Widget 6
 *  [Jacob Peattie](https://wordpress.org/support/users/jakept/)
 * (@jakept)
 * [8 years, 9 months ago](https://wordpress.org/support/topic/html-code-after-third-widget/#post-9257843)
 * This code will do what you’re after:
 *     ```
       function my_between_widgets( $widget ) {
       	if ( is_admin() ) {
       		return;
       	}
   
       	// Get list of all sidebars and which widgets they have.
       	$sidebars_widgets = get_option( 'sidebars_widgets' );
   
       	// Check the position of the current widget in the widget area I want.
       	$position = array_search( $widget['id'], $sidebars_widgets['sidebar'] );
   
       	// If it's after the 3rd widget, do something.
       	if ( $position === 3 ) {
       		// Add code here.
       	}
       }
       add_action( 'dynamic_sidebar', 'my_between_widgets' );
       ```
   
 * You’ll need to replace the `'sidebar'` in `$sidebars_widgets['sidebar']` with
   the actual name of the widget area you want to do this in though.
 * If you wanted to put it after every third widget or something, you’d just change`
   $position === 3` to something checking if it’s divisible by 3, or whatever number
   you want.
 * Depending on what you’re doing though, it might be easier to just add the HTML
   you want as a 4th widget, and use `:nth-child(4)` or `nth-child(4n)`(for every
   4th widget) in CSS to style it differently/clear floats etc.
    -  This reply was modified 8 years, 9 months ago by [Jacob Peattie](https://wordpress.org/support/users/jakept/).
    -  This reply was modified 8 years, 9 months ago by [Jacob Peattie](https://wordpress.org/support/users/jakept/).
    -  This reply was modified 8 years, 9 months ago by [Jacob Peattie](https://wordpress.org/support/users/jakept/).
 *  Thread Starter [autox420](https://wordpress.org/support/users/autox420/)
 * (@autox420)
 * [8 years, 9 months ago](https://wordpress.org/support/topic/html-code-after-third-widget/#post-9258328)
 * In what file i do i need to add that code?
    And where do i put html code cause
   i dont see that u put something extra as ”test” in your code.
 * My widgets i use as widget 1 widget 2 widget 3 is ”text” widget so whats the 
   name of those widgets, the third one?
 * _The .css option didnt work it causes a bug._
    -  This reply was modified 8 years, 9 months ago by [autox420](https://wordpress.org/support/users/autox420/).
 *  Thread Starter [autox420](https://wordpress.org/support/users/autox420/)
 * (@autox420)
 * [8 years, 9 months ago](https://wordpress.org/support/topic/html-code-after-third-widget/#post-9258811)
 * Well i cant figger it out.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Html code after third widget’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 5 replies
 * 3 participants
 * Last reply from: [autox420](https://wordpress.org/support/users/autox420/)
 * Last activity: [8 years, 9 months ago](https://wordpress.org/support/topic/html-code-after-third-widget/#post-9258811)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
