Newsletters: Filter – wpml_post_anchor_style
Description
The wpml_post_anchor_style
provides a custom inline style for the post anchor link. You can use this filter to add inline style based on post type or by determining the $post object and defining your own conditions. It will be added to the emails, as inline style.
It is useful when you want to modify the styling of your newsletter post title links and ensure the formatting remains consistent during email forwarding, as inline styles are used instead of embedded CSS classes or external styles in your email template.
Usage
<<?php add_filter('wpml_post_anchor_style', 'child_theme_get_post_anchor_style', 10, 4); ?>
Arguments
$style
– The default style (from alignment/hspace, or empty).$post_id
– The post ID.$post_type
– The post type.$post
– The full post object.
Example
<?php
/**
* Provide a custom inline style for the post anchor link.
*
* @param string $style The default style (empty by default).
* @param int $post_id The post ID.
* @param string $post_type The post type.
* @param WP_Post $post The full post object.
* @return string The inline style string.
*/
function child_theme_get_post_anchor_style($style, $post_id, $post_type, $post) {
if ($post_type === 'post') {
return 'font-family: Arial, Helvetica, sans-serif; font-size: 17px; color: rgb(0, 130, 120); line-height: 1.4em;';
}
return $style;
}
add_filter('wpml_post_anchor_style', 'child_theme_get_post_anchor_style', 10, 4);
?>
Beautiful Newsletter Templates
Professional newsletter templates that are fully responsive for desktop, tablet, and mobile. They are 100% cross-client compatible.