Assign Native Post Data to a Skin Element

Grab information already available in your posts. And then assign it data to a skin element using the following PHP.

Step 1:

Edit/Add an element inside the Item Skin Editor, wrapping the post data attribute in percentage characters.

Step 2:

Add the following code to your theme’s “functions.php” file.

add_filter('essgrid_post_meta_handle', 'eg_add_post_option');
add_filter('essgrid_post_meta_content', 'eg_add_post_content', 10, 4);
 
function eg_add_post_option($post_options){
 
// where 'author_id' is the attribute of the data to pull in
$post_options['author_id'] = array('name' => 'Author ID');
 
return $post_options;
 
}
 
function eg_add_post_content($meta_value, $meta, $post_id, $post){
 
// where 'author_id' is the attribute of the data to pull in
if($meta === 'author_id'){
 
$post_author_id = get_post_field( 'post_author', $post_id );
 
// return the post data value, and wrap it in any HTML you want
return '<div class="author-id">Author ID = '.$post_author_id.'</div>';
 
}
 
return $meta_value;
 
}
Assign Native Post Data to a Skin Element

Further Resources for Web Design and Development Enthusiasts

Alright! We've embarked on quite an adventure exploring the realms of this topic. But why stop there? The world of web design and development is vast, and there's always more to learn and discover. Let's dive into some resources that'll keep your knowledge fresh, your skills sharp, and your passion ignited:

The Author

KC

Strength does not come from winning. Your struggles develop your strengths. When you go through hardships and decide not to surrender, that is strength.

Liked this Post?
Please Share it!