• Resolved katasun

    (@katasun)


    In WordPress 5.8.2 is a block function, calling the lastest posts.

    latest-posts

    The function lists latest post and the title of the post. I need to add a class to the title link.

    $title = get_the_title( $post );
    		if ( ! $title ) {
    			$title = __( '(no title)' );
    		}
                    
    		$list_items_markup .= sprintf(
    			'<a class="wp-block-button__link add_to_cart_button" href="%1$s">%2$s</a>',
    			$post_link,
    			$title
                            
    		);

    This works fine in latest-posts.php, but I am not able to override the function properly. Maybe someone knows a snippet how to do this. In other words I need to change the code of latest-posts.php in the right form, so it will not be deleted by updates. I would be very happy about any tipp.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    Thread Starter katasun

    (@katasun)

    Thank you very much for the answer, this is a good solution. But i did not found the right command to exclude the function only to the headlines to the gutenberg blocks.

    But I have a solution that works only with css from another forum:

    you can use the block class and define a css rule only for the headlines within blocks

    .wp-block-latest-posts li > a { color: red; }

    in the block setting there is a form field on the bottom where you can add you own classes for this type of block.

    .verynew li > a { font-weight: bold; }`

    Thanks a lot
    katasun

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Override latest-posts.php’ is closed to new replies.