Posts on Profile (Author) Page

Hello Team

I am looking to use essential grid to showcase the author’s posts on their profile page on our runner.noble-pro.com site. We use the ultimate members plugin which allows you to edit users profile templates and enables us to identify the user profile using um_profile_id. The idea is to identify the profile_id and use this as the author_id with the Essential Grid’s built-in plugin filters to only show the posts by the author on their profile page.

I have successfully got the profile_id (author_id) using the um_profile_id however I have been unsuccessful getting the “apply advanced post queries using one of Essential Grid’s built-in plugin filters” to only show the post from the relevant author on their profile page.

I have added the following to the function.php file:

/* Ess Grid Profile Posts filter */

$profile_id = um_profile_id();
 		
add_filter('essgrid_query_caching', 'eg_stop_caching', 10, 2);
add_filter('essgrid_get_posts', 'eg_mod_query', 10, 2);
		
/* turn off caching for your grid */
function eg_stop_caching($do_cache, $grid_id) {
 
	if($grid_id == YOUR_GRID_ID) return false;
	return true;
 
		}
		
function eg_mod_query($query, $grid_id){
 
	if($grid_id == 6){
 
	$query['meta_query'] = array( 'author' == 32 );
						
			/*
			*https://www.themepunch.com/faq/advanced-additional-parameters/
			*/
 		}		
		return $query;
 		}

Added the following to the profile.php:

<?php
		
	// Ess. Grid shortcode is placed inside the "do_shortcode" method, wrapped in single quotes
  	echo do_shortcode('[ess_grid alias="profile_posts"]');
		 	   
?>

Please could you assist with how to filter the essential grid posts to only show the author’s posts on their profile page.

Note: The profile.php file has the above commented out while the issues is being resolved.

Hello Stefan,

Thanks for writing in!

In your code, you are using a fixed author ID. You might need to get the author ID.

Regretfully this requires custom coding which is beyond the scope of our support. You may need to contact 3rd party development to accomplish what you need.

Please note that custom coding is outside the scope of our support. Issues that might arise from the use of custom code and further enhancements should be directed to a third party developer.

Thank you for your understanding.

I have managed to solve the get it working by adding the following to the ultimate member profile.php which utilises the search function to show the posts bt only the specific author:

add_action('um_profile_content_mycustomtab_default', 'um_profile_content_mycustomtab_default');
function um_profile_content_mycustomtab_default( $args ) {
	$author = um_profile_id();

$args = array(
	'author'    => $author,
   	/*'showposts' => -1,*/ 
	'posts_per_page' => -1, 
    	/*'post_type' => 'post' */
);


$tp_allsearch = new WP_Query($args);

$posts = array();

if($tp_allsearch->have_posts()) :
 
   
    while($tp_allsearch->have_posts()) : $tp_allsearch->the_post();
    
   
    $posts[] = get_the_ID(); 
    
     
endwhile;
else:
    return false;
endif;

$the_content = do_shortcode('[ess_grid alias="profile_posts" posts="'.implode(',', $posts).'"]');
 
echo $the_content;
		
}

Hey Stefan,

We are just glad that you have figured it out a way to correct the said issue.
Thanks for letting us know!

Best Regards.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.