Hi @tom2,
{secondary_title} isn’t a valid Content Tag. It doesn’t exist or at least WordPress Popular Posts doesn’t include it as it’s not a stock WordPress feature.
You can register it as a custom Content Tag though by using the wpp_parse_custom_content_tags filter hook (but you’ll have to write the logic for this to work, don’t just copy & paste any code you see somewhere.)
I actually wanted to make the title appear. secondary title
if you can help me thank you very much.
Alright, that link helped.
This is what you need:
/**
* Parses custom content tags in WordPress Popular Posts.
*
* @param string $html The HTML markup from the plugin.
* @param integer $post_id The post/page ID.
* @return string
*/
function wpp_parse_tags_in_popular_posts($html, $post_id){
// Replace custom content tag {secondary_title}
// with the actual secondary title
if (
false !== strpos($html, '{secondary_title}')
&& function_exists('has_secondary_title')
) {
// If the post has a secondary title, replace
// the content tag {secondary_title} with
// the secondary title
if ( has_secondary_title($post_id) ) {
$secondary_title = get_secondary_title($post_id);
$html = str_replace('{secondary_title}', $secondary_title, $html);
}
}
return $html;
}
add_filter("wpp_parse_custom_content_tags", "wpp_parse_tags_in_popular_posts", 10, 2);
Add that code snippet to your theme’s functions.php file and you’re good to go.
You’ll want to read the code to see what it does. This should help you understand a little better how PHP works in general.
-
This reply was modified 5 years, 9 months ago by
Hector Cabrera. Reason: Fixed typo in code
if it is not too uncomfortable help me with this thing.
I would also like to show the artists for each album.
tried this more it worked.
<?php
$songId = get_the_ID();
$artistaId = get_post_meta($songId, 'theme2035_album_artista_name', true);
if($artistaId != ""){
$get_artista_name = new WP_Query( array(
'post_type' => 'artista',
'posts_per_page' => -1,
'p' => $artistaId,
));
if( $get_artista_name->have_posts() ) :
while( $get_artista_name->have_posts() ) : $get_artista_name->the_post();
$artista_name = get_the_title();
$artista_link = get_permalink();
endwhile;
endif;
?>
<a href="<?php echo esc_attr($artista_link); ?>"><?php echo esc_attr($artista_name); ?></a>
/**
* Parses custom content tags in WordPress Popular Posts.
*
* @param string $html The HTML markup from the plugin.
* @param integer $post_id The post/page ID.
* @return string
*/
function wpp_parse_tags_in_popular_posts($html, $post_id){
// Replace custom content tag {artista_name}
// with the actual secondary title
if (
false !== strpos($html, '{artista_name}')
&& function_exists('has_artista_name')
) {
// If the post has a secondary title, replace
// the content tag {artista_name} with
// the secondary title
if ( has_artista_name($post_id) ) {
$artista_name = get_artista_name($post_id);
$html = str_replace('{artista_name}', $get_artista_name, $html);
}
}
// Replace custom content tag {secondary_title}
// with the actual secondary title
if (
false !== strpos($html, '{secondary_title}')
&& function_exists('has_secondary_title')
) {
// If the post has a secondary title, replace
// the content tag {secondary_title} with
// the secondary title
if ( has_secondary_title($post_id) ) {
$secondary_title = get_secondary_title($post_id);
$html = str_replace('{secondary_title}', $secondary_title, $html);
}
}
return $html;
}
add_filter("wpp_parse_custom_content_tags", "wpp_parse_tags_in_popular_posts", 10, 2);
if possible how to add get_permalink (); on them
For the artist thing, I’m sorry but you’ll have to do some research and try to figure it out on your own. I think I’ve already helped you plenty with stuff that’s not directly related to the plugin.
Regarding the permalink, you can use the {url} Content Tag to obtain the URL of the post. You really should check the Content Tags documentation to see what’s available and save yourself some time (WP Dashboard > Settings > WordPress Popular Posts > Parameters, near the end of the page.)
I understand
I can make a donation and you can help me with this, if possible, or how much you charge to do this.
please
Unfortunately offering/requesting paid jobs here in the forums is not allowed (see Forum Guidelines.) You may want to consider posting a job offer at WP Jobs to find someone who can lend you a hand with this.
sorry about that
and thanks for helping me.