google-site-verification=Ls9KcWrF2YZT7kMIaBSLGLUrYl--Png3qoN53OOo4WM Filters/Actions for Post - Spectra

No results found. Try again with different words?

Search must be at least 3 characters.

Filters/Actions for Post

Actions/Filters available for Posts Block are listed below.
The parameters used in the below actions/filters are one of the below-listed options. The detailed description of these parameters is as specified below.

  • $attributes : This is the entire setting array for the particular dragged dropped Post Block. One can add conditional logic as per the selected options in the settings.
  • $post_id : This is the single post ID in the loop. This is useful when one wants to fetch post specific data and display it.
  • POST_BLOCK_TYPE : This is the type of Post Block you are using – grid/masonry/carousel

uagb_post_query_args_{POST_BLOCK_TYPE}

This filter modifies the Query Arguments for Post Grid, Post Masonry, Post Carousel, Post Timeline, etc.

function filter_post_query( $query_args, $attributes) {
    // Modify $query_args values.
    // Ex.
    $query_args[\'ignore_sticky_posts\'] = 0;
    return $query_args;
} 
add_filter( \'uagb_post_query_args_grid\', \'filter_post_query\', 10, 2 );

uagb_enable_post_class

This filter enables the `post_class()` compatibility to the respective Post Grid, Masonry, Carousel block.

add_filter( \'uagb_enable_post_class\', \'__return_true\' );

uagb_post_before_article_{POST_BLOCK_TYPE}

Fires at the beginning of the single post article tag

function single_post_before( $post_id, $attributes ) {
    echo \'<div> I am at the beginning of the single post wrap. </div>\'; 
} 
add_action( \'uagb_post_before_article_grid\', \'single_post_before\', 10, 2 );

uagb_post_after_article_{POST_BLOCK_TYPE}

Fires at the end of the single post article tag

function single_post_after( $post_id, $attributes ) {
    echo \'<div> I am at the end of the single post wrap. </div>\'; 
} 
add_action( \'uagb_post_after_article_grid\', \'single_post_after\', 10, 2 );

uagb_post_before_inner_wrap_{POST_BLOCK_TYPE}

Fires at the beginning of the single post inner wrap

function single_post_inner_wrap_before( $post_id, $attributes ) {
    echo \'<div> I am at the beginning of the single post inner wrap. </div>\'; 
} 
add_action( \'uagb_post_before_inner_wrap_grid\', \'single_post_inner_wrap_before\', 10, 2 );

uagb_post_after_inner_wrap_{POST_BLOCK_TYPE}

Fires at the end of the single post inner wrap

function single_post_inner_wrap_after( $post_id, $attributes ) {
    echo \'<div> I am at the end of the single post inner wrap. </div>\'; 
} 
add_action( \'uagb_post_after_inner_wrap_grid\', \'single_post_inner_wrap_after\', 10, 2 );

uagb_single_post_before_featured_image_{POST_BLOCK_TYPE}

Fires at the beginning of the single post featured image

function single_post_featured_image_before( $post_id, $attributes ) {
    echo \'<div> I am at the beginning of the single post featured image. </div>\'; 
} 
add_action( \'uagb_single_post_before_featured_image_grid\', \'single_post_featured_image_before\', 10, 2 );

uagb_single_post_after_featured_image_{POST_BLOCK_TYPE}

Fires at the end of the single post featured image

function single_post_featured_image_after( $post_id, $attributes ) {
    echo \'<div> I am at the end of the single post featured image. </div>\'; 
} 
add_action( \'uagb_single_post_after_featured_image_grid\', \'single_post_featured_image_after\', 10, 2 );

uagb_single_post_before_title_{POST_BLOCK_TYPE}

Fires at the beginning of the single post title

function single_post_title_before( $post_id, $attributes ) {
    echo \'<div> I am at the beginning of the single post title. </div>\'; 
} 
add_action( \'uagb_single_post_before_title_grid\', \'single_post_title_before\', 10, 2 );

uagb_single_post_after_title_{POST_BLOCK_TYPE}

Fires at the end of the single post title

function single_post_title_after( $post_id, $attributes ) {
    echo \'<div> I am at the end of the single post title. </div>\'; 
} 
add_action( \'uagb_single_post_after_title_grid\', \'single_post_title_after\', 10, 2 );

uagb_single_post_before_meta_{POST_BLOCK_TYPE}

Fires at the beginning of the single post meta

function single_post_meta_before( $post_id, $attributes ) {
    echo \'<div> I am at the beginning of the single post meta. </div>\'; 
} 
add_action( \'uagb_single_post_before_meta_grid\', \'single_post_meta_before\', 10, 2 );

uagb_single_post_after_meta_{POST_BLOCK_TYPE}

Fires at the end of the single post meta

function single_post_meta_after( $post_id, $attributes ) {
    echo \'<div> I am at the end of the single post meta. </div>\'; 
} 
add_action( \'uagb_single_post_after_meta_grid\', \'single_post_meta_after\', 10, 2 );

uagb_single_post_before_excerpt_{POST_BLOCK_TYPE}

Fires at the beginning of the single post excerpt

function single_post_excerpt_before( $post_id, $attributes ) {
    echo \'<div> I am at the beginning of the single post excerpt. </div>\'; 
} 
add_action( \'uagb_single_post_before_excerpt_grid\', \'single_post_excerpt_before\', 10, 2 );

uagb_single_post_after_excerpt_{POST_BLOCK_TYPE}

Fires at the end of the single post excerpt

function single_post_excerpt_after( $post_id, $attributes ) {
    echo \'<div> I am at the end of the single post excerpt. </div>\'; 
} 
add_action( \'uagb_single_post_after_excerpt_grid\', \'single_post_excerpt_after\', 10, 2 );

uagb_single_post_excerpt_{POST_BLOCK_TYPE}

This filter is used to allow customization in post excerpt (i.e. to display video/images/links) for the Post Grid, Post Masonry, Post Carousel, Post Timeline, etc. Below is the example for \”Post Grid\”:

add_filter(\'uagb_single_post_excerpt_grid\', function($excerpt, $id, $attr) { return custom_post_content(30); },10, 3 );
  
function custom_post_content($limit) {
	global $post;
	$content = explode(\' \', the_content(), $limit);
	if (count($content)>=$limit) {
	array_pop($content);
	$content = implode(\" \",$content);
	} else {
	$content = implode(\" \",$content);
	}	
	$content = preg_replace(\'/\\[.+\\]/\',\'\', $content);
	$content = apply_filters(\'the_content\', $content); 
	$content = str_replace(\']]>\', \']]&gt;\', $content);
	return $content;
}

uagb_single_post_before_cta_{POST_BLOCK_TYPE}

Fires at the beginning of the single post cta

function single_post_cta_before( $post_id, $attributes ) {
    echo \'<div> I am at the beginning of the single post cta. </div>\'; 
} 
add_action( \'uagb_single_post_before_cta_grid\', \'single_post_cta_before\', 10, 2 );

uagb_single_post_after_cta_{POST_BLOCK_TYPE}

Fires at the end of the single post cta

function single_post_cta_after( $post_id, $attributes ) {
    echo \'<div> I am at the end of the single post cta. </div>\'; 
} 
add_action( \'uagb_single_post_after_cta_grid\', \'single_post_cta_after\', 10, 2 );

Build Ultra High performance
Websites, Without Coding

Whether you are a beginner, marketer, or professional, Spectra has the
tools and resources you can rely on to succeed.

Download is Just A Click Away!

Enter your email address and be the first to learn about updates and new features.