这可以通过使用基于最大宽度和文本溢出属性的简单css来实现。
<style>
/**
* note that your theme might not use class nav_posts
* so you might have to adjust to your need
*/
.nav_posts .title {
/**
* This is what is minimum required for the magic
* First it has to be a block... inline blocks are cool and simple to use,
* but if your theme used blocks (includes flex) don\'t upset him and take that line out
*/
display: inline-block;
text-overflow: ellipsis;
/* Required for text-overflow to do anything */
overflow: hidden;
white-space: nowrap; /* forces text to fit on one line */
max-width: 30ex; /* Fit to your needs... */
/* Then what ever you need to fit in your theme */
vertical-align: bottom;
}
</style>
<!--
// Check out your theme (could be in single.php)
// the below php is only to illustrate the case.
// Make your life simple, don\'t edit the theme or any php, adjust the css
// adding it using wordpress custom css, nothing more, as simple as that :)
-->
<?php
previous_post_link(\'<span class="nav_posts left">← <span class="title">%link</span></span>\');
next_post_link(\'<span class="nav_posts right"><span class="title">%link</span> →</span>\');
?>