如何在 widget wordpress 中制作 "read more" link?
How to make a "read more" link in widget wordpress?
我是 wordpress 新手。我想创建 "read more" link 到详细的文章,因为有时它太长了。我该怎么做?请帮助我。
我的照片:
我的代码:our_team.php
<?php
echo '<section class="our-team" id="team">';
echo '<div class="container">';
echo '<div class="section-header">';
$zerif_ourteam_title = get_theme_mod('zerif_ourteam_title',__('YOUR TEAM','zerif-lite'));
if( !empty($zerif_ourteam_title) ):
echo '<h2 class="dark-text">'.$zerif_ourteam_title.'</h2>';
endif;
$zerif_ourteam_subtitle = get_theme_mod('zerif_ourteam_subtitle',__('Prove that you have real people working for you, with some nice looking profile pictures and links to social media.','zerif-lite'));
if( !empty($zerif_ourteam_subtitle) ):
echo '<div class="section-legend">'.$zerif_ourteam_subtitle.'</div>';
endif;
echo '</div>';
if(is_active_sidebar( 'sidebar-ourteam' )):
echo '<div class="row" data-scrollreveal="enter left after 0s over 0.1s">';
dynamic_sidebar( 'sidebar-ourteam' );
echo '</div> ';
else:
echo '<div class="row" data-scrollreveal="enter left after 0s over 0.1s">';
the_widget( 'zerif_team_widget','name=ASHLEY SIMMONS&position=Project Manager&description=Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc dapibus, eros at accumsan auctor, felis eros condimentum quam, non porttitor est urna vel neque&fb_link=#&tw_link=#&bh_link=#&db_link=#&ln_link=#&image_uri='.get_template_directory_uri().'/images/team1.png', array('before_widget' => '', 'after_widget' => '') );
the_widget( 'zerif_team_widget','name=TIMOTHY SPRAY&position=Art Director&description=Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc dapibus, eros at accumsan auctor, felis eros condimentum quam, non porttitor est urna vel neque&fb_link=#&tw_link=#&bh_link=#&db_link=#&ln_link=#&image_uri='.get_template_directory_uri().'/images/team2.png', array('before_widget' => '', 'after_widget' => '') );
the_widget( 'zerif_team_widget','name=TONYA GARCIA&position=Account Manager&description=Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc dapibus, eros at accumsan auctor, felis eros condimentum quam, non porttitor est urna vel neque&fb_link=#&tw_link=#&bh_link=#&db_link=#&ln_link=#&image_uri='.get_template_directory_uri().'/images/team3.png', array('before_widget' => '', 'after_widget' => '') );
the_widget( 'zerif_team_widget','name=JASON LANE&position=Business Development&description=Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc dapibus, eros at accumsan auctor, felis eros condimentum quam, non porttitor est urna vel neque&fb_link=#&tw_link=#&bh_link=#&db_link=#&ln_link=#&image_uri='.get_template_directory_uri().'/images/team4.png', array('before_widget' => '', 'after_widget' => '') );
echo '</div>';
endif;
echo '</div>';
echo '</section>';
首先,准备着陆页。
您想创建 "read more" link,它必须指向某个地方。如果您已经拥有 "somewhere",请跳过此步骤。
首先创建普通的 Wordpress 页面。将其命名为 "Team"、"About Us" 或类似名称。显然,该页面应包含有关每个团队成员的一些信息。使用唯一 ID 包装 div 中每个人的信息(我会为此使用一些名称变体):
<div id="ashley">
... About Ashley HTML
</div>
记住页面地址(显示在标题字段下方)。
然后,修改小部件。
在你截屏的地方,你可以点击这些面朝下的箭头来修改主页上每个人的信息。大多数字段不允许在内容中包含 HTML,但 Position 和 Description 是例外[1]。只要您能够手写 HTML,就可以包含 link。
只需遵循此模板:
<a href="[address of page]#[id of person]">Read more</a>
其中:
[address of page]
是您在第一步中创建的页面地址(/team/
、/about-us/
或其他内容)
[id of person]
是 div 的 id
属性的内容,它包装了有关特定人的信息(ashley
等)
- 不要忘记之间的数字符号(
#
)!
小部件内容如下所示:
最后,审核描述内容。
你说的描述是"sometimes too long"。问题是您对用户如何查看您的页面的控制非常有限。由于视口宽度有限,您可以接受长度的文本在移动设备上可能会变得太长。
我建议您在主页上使用简短描述,并在单独的页面上提供较长的文本。通过这种方式,您还将确保每个团队成员在主页和单独页面上都有 "Read more" link,不会遗漏任何人。
此方法的一个 巨大缺点 是它全是手动的。您有责任使两个页面保持同步。如果您决定更改团队组成或任何团队成员更改姓名,这一点尤其重要。您还必须确保在两个地方使用相同的图像。
这是必要的,因为这个主题使用小部件在主页上生成数据,而小部件是在任何地方显示一些内容的东西。没有 page 与 widget 相关联,因此默认情况下,您无法将用户发送到任何地方。
当然可以动态生成 "About" 页面,或者修改主页面以显示除小部件以外的其他内容,但这可能超出了本网站简单回答的范围。
[1] 这些字段的内容在显示之前是运行到wp_filter_post_kses
。该函数去除 $allowedposttags
全局数组中不存在的所有标签。该数组可以被 CUSTOM_TAGS
常量覆盖,并且 允许插件修改它 .
我是 wordpress 新手。我想创建 "read more" link 到详细的文章,因为有时它太长了。我该怎么做?请帮助我。
我的照片:
我的代码:our_team.php
<?php
echo '<section class="our-team" id="team">';
echo '<div class="container">';
echo '<div class="section-header">';
$zerif_ourteam_title = get_theme_mod('zerif_ourteam_title',__('YOUR TEAM','zerif-lite'));
if( !empty($zerif_ourteam_title) ):
echo '<h2 class="dark-text">'.$zerif_ourteam_title.'</h2>';
endif;
$zerif_ourteam_subtitle = get_theme_mod('zerif_ourteam_subtitle',__('Prove that you have real people working for you, with some nice looking profile pictures and links to social media.','zerif-lite'));
if( !empty($zerif_ourteam_subtitle) ):
echo '<div class="section-legend">'.$zerif_ourteam_subtitle.'</div>';
endif;
echo '</div>';
if(is_active_sidebar( 'sidebar-ourteam' )):
echo '<div class="row" data-scrollreveal="enter left after 0s over 0.1s">';
dynamic_sidebar( 'sidebar-ourteam' );
echo '</div> ';
else:
echo '<div class="row" data-scrollreveal="enter left after 0s over 0.1s">';
the_widget( 'zerif_team_widget','name=ASHLEY SIMMONS&position=Project Manager&description=Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc dapibus, eros at accumsan auctor, felis eros condimentum quam, non porttitor est urna vel neque&fb_link=#&tw_link=#&bh_link=#&db_link=#&ln_link=#&image_uri='.get_template_directory_uri().'/images/team1.png', array('before_widget' => '', 'after_widget' => '') );
the_widget( 'zerif_team_widget','name=TIMOTHY SPRAY&position=Art Director&description=Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc dapibus, eros at accumsan auctor, felis eros condimentum quam, non porttitor est urna vel neque&fb_link=#&tw_link=#&bh_link=#&db_link=#&ln_link=#&image_uri='.get_template_directory_uri().'/images/team2.png', array('before_widget' => '', 'after_widget' => '') );
the_widget( 'zerif_team_widget','name=TONYA GARCIA&position=Account Manager&description=Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc dapibus, eros at accumsan auctor, felis eros condimentum quam, non porttitor est urna vel neque&fb_link=#&tw_link=#&bh_link=#&db_link=#&ln_link=#&image_uri='.get_template_directory_uri().'/images/team3.png', array('before_widget' => '', 'after_widget' => '') );
the_widget( 'zerif_team_widget','name=JASON LANE&position=Business Development&description=Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc dapibus, eros at accumsan auctor, felis eros condimentum quam, non porttitor est urna vel neque&fb_link=#&tw_link=#&bh_link=#&db_link=#&ln_link=#&image_uri='.get_template_directory_uri().'/images/team4.png', array('before_widget' => '', 'after_widget' => '') );
echo '</div>';
endif;
echo '</div>';
echo '</section>';
首先,准备着陆页。
您想创建 "read more" link,它必须指向某个地方。如果您已经拥有 "somewhere",请跳过此步骤。
首先创建普通的 Wordpress 页面。将其命名为 "Team"、"About Us" 或类似名称。显然,该页面应包含有关每个团队成员的一些信息。使用唯一 ID 包装 div 中每个人的信息(我会为此使用一些名称变体):
<div id="ashley">
... About Ashley HTML
</div>
记住页面地址(显示在标题字段下方)。
然后,修改小部件。
在你截屏的地方,你可以点击这些面朝下的箭头来修改主页上每个人的信息。大多数字段不允许在内容中包含 HTML,但 Position 和 Description 是例外[1]。只要您能够手写 HTML,就可以包含 link。
只需遵循此模板:
<a href="[address of page]#[id of person]">Read more</a>
其中:
[address of page]
是您在第一步中创建的页面地址(/team/
、/about-us/
或其他内容)[id of person]
是 div 的id
属性的内容,它包装了有关特定人的信息(ashley
等)- 不要忘记之间的数字符号(
#
)!
小部件内容如下所示:
最后,审核描述内容。
你说的描述是"sometimes too long"。问题是您对用户如何查看您的页面的控制非常有限。由于视口宽度有限,您可以接受长度的文本在移动设备上可能会变得太长。
我建议您在主页上使用简短描述,并在单独的页面上提供较长的文本。通过这种方式,您还将确保每个团队成员在主页和单独页面上都有 "Read more" link,不会遗漏任何人。
此方法的一个 巨大缺点 是它全是手动的。您有责任使两个页面保持同步。如果您决定更改团队组成或任何团队成员更改姓名,这一点尤其重要。您还必须确保在两个地方使用相同的图像。
这是必要的,因为这个主题使用小部件在主页上生成数据,而小部件是在任何地方显示一些内容的东西。没有 page 与 widget 相关联,因此默认情况下,您无法将用户发送到任何地方。
当然可以动态生成 "About" 页面,或者修改主页面以显示除小部件以外的其他内容,但这可能超出了本网站简单回答的范围。
[1] 这些字段的内容在显示之前是运行到wp_filter_post_kses
。该函数去除 $allowedposttags
全局数组中不存在的所有标签。该数组可以被 CUSTOM_TAGS
常量覆盖,并且 允许插件修改它 .