2
I needed to create a filter to print the name and email of users within posts (the_content
) that they create.
The problem is that it is showing in the posts and also in the pages, I wanted to show only in the POSTS, I tried so and it did not work:
function my_content($content) {
$content .= "<b>Nome do comprador:</b> " . usp_get_meta(false, 'usp-author') . "<br />";
$content .= "<b>Email do comprador:</b> " . usp_get_meta(false, 'usp-email');
return $content;
}
if (!is_page_template('page.php'))
remove_filter('the_content','my_content');
else
add_filter('the_content','my_content');
It shows right in the posts, but it is printing on the pages also (Buyer’s name: and Buyer’s email:). How to remove these page impressions?
Raphael, I’m trying: if(is_single() || !is_page_template('template_fullwidth.php', 'page.php')) and he doesn’t want to consider page.php, pq?
– GustavoCave
For page.php you can use
is_page()
, thus getting your parole tag:if(is_single() || !is_page_template('page.php') || !is_page())
orif(is_single() && !is_page_template('page.php') && !is_page())
.– Rafael Alexandre