Wordpress 如何使用wp_trim_单词并阅读更多内容?
我需要使用Wordpress 如何使用wp_trim_单词并阅读更多内容?,wordpress,Wordpress,我需要使用wp\u trim\u words()函数,以及一个“阅读更多”文本,当单击该文本时,它会在下方显示其余内容,如切换 这可能吗?试试这个 <?php echo wp_trim_words(get_the_content(), 40, '...'); ?> 或 或 对于tuggle,您需要使用javascript或jquery。使用jquery/script时,无需使用wp\u trim\u words函数,只需使用一些带有ancher标记(控件)的文本,并在单
wp\u trim\u words()
函数,以及一个“阅读更多”文本,当单击该文本时,它会在下方显示其余内容,如切换
这可能吗?试试这个
<?php
echo wp_trim_words(get_the_content(), 40, '...');
?>
或
或
对于tuggle,您需要使用javascript或jquery。使用jquery/script时,无需使用wp\u trim\u words函数,只需使用一些带有ancher标记(控件)的文本,并在单击时隐藏/显示一些内容。要显示页面内容,您可能需要使用内容()或echo get\u内容()。但是,你只需要使用下面的行
echo wp_trim_words(get_the_content(), $string_length, $text_read_more_optional); //example, $string_length=50, $text_read_more_optinal='Read More'
我猜你的代码应该是这样的:
if(have_posts()){
while(have_posts()){
the_post();
the_title(); //display title
echo wp_trim_words(get_the_content(), 100, 'Read More'); //display content
}
}
你在找类似的东西吗?到目前为止你试过什么?将当前代码添加到问题Davy M,是!但应用于wp_trim_words()函数。cmaher echo wp_trim_words(获取内容(),40,“…”);我需要一个“阅读更多”按钮,点击该按钮时显示其余内容。您知道一种根据浏览器分辨率使用不同的wp_trim_单词(…)字长的方法吗?
echo wp_trim_words(get_the_content(), $string_length, $text_read_more_optional); //example, $string_length=50, $text_read_more_optinal='Read More'
if(have_posts()){
while(have_posts()){
the_post();
the_title(); //display title
echo wp_trim_words(get_the_content(), 100, 'Read More'); //display content
}
}