Title: Undefined variable: advanced_post_list
Last modified: September 11, 2018

---

# Undefined variable: advanced_post_list

 *  Resolved [cexpert](https://wordpress.org/support/users/cexpert/)
 * (@cexpert)
 * [7 years, 8 months ago](https://wordpress.org/support/topic/undefined-variable-advanced_post_list/)
 * I am trying to add the display of an APL at the end of the header using the et_before_main_content
   action hook provided by Divi theme.
 * so I added the following
    ` if( !function_exists('post_grid_in_header') ) { function
   post_grid_in_header() { if (method_exists($advanced_post_list, "display_post_list")){
   echo $advanced_post_list->display_post_list("top_4_features_row"); } } add_action('
   et_before_main_content', 'post_grid_in_header' ); }
 * in the theme child’s function.php file.
 * As result I get: Undefined variable: advanced_post_list
 * Please advise.

Viewing 1 replies (of 1 total)

 *  Plugin Support [Advanced Post List](https://wordpress.org/support/users/advancedpostlist/)
 * (@advancedpostlist)
 * [7 years, 8 months ago](https://wordpress.org/support/topic/undefined-variable-advanced_post_list/#post-10678585)
 * An update recently made `$advanced_post_list` into a global to resolve issues
   like this.
 * If you replace the code with this, should resolve the issue.
 *     ```
       if( !function_exists('post_grid_in_header') ) {
       	function post_grid_in_header() {
       		global $advanced_post_list;
       		if (method_exists($advanced_post_list, "display_post_list")) {
       			echo $advanced_post_list->display_post_list("top_4_features_row");
       		}
       	}
       	add_action( 'et_before_main_content', 'post_grid_in_header' );
       }
       ```
   
    -  This reply was modified 7 years, 8 months ago by [Advanced Post List](https://wordpress.org/support/users/advancedpostlist/).
      Reason: comma missing

Viewing 1 replies (of 1 total)

The topic ‘Undefined variable: advanced_post_list’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/advanced-post-list.svg)
 * [Advanced Post List](https://wordpress.org/plugins/advanced-post-list/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/advanced-post-list/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/advanced-post-list/)
 * [Active Topics](https://wordpress.org/support/plugin/advanced-post-list/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/advanced-post-list/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/advanced-post-list/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Advanced Post List](https://wordpress.org/support/users/advancedpostlist/)
 * Last activity: [7 years, 8 months ago](https://wordpress.org/support/topic/undefined-variable-advanced_post_list/#post-10678585)
 * Status: resolved