Created
November 8, 2018 07:58
-
-
Save bappi-d-great/585bb6ffeb703e500e84f2073d495723 to your computer and use it in GitHub Desktop.
Forminator add more email macro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Email macro: {last-post-link} | |
add_filter( 'forminator_replace_variables', function( $content, $content_before_replacement ) { | |
$args = array( 'numberposts' => '1' ); | |
$recent_posts = wp_get_recent_posts( $args ); | |
$post = '<a href="' . get_permalink( $recent_posts[0]['ID'] ) . '">' . get_the_title( $recent_posts[0]['ID'] ) . '</a>'; | |
return str_replace( '{last-post-link}', $post, $content ); | |
}, 99, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment