Php 更改“阅读更多”和“评论”的文本
我有波兰语的网站,这就是为什么我要翻译所有的元素 待办事项:Php 更改“阅读更多”和“评论”的文本,php,html,wordpress,Php,Html,Wordpress,我有波兰语的网站,这就是为什么我要翻译所有的元素 待办事项: 翻译按钮阅读更多 翻译“无评论”(当0条评论要发布时,显示“无评论”,但当我至少有一条评论时,我有正确的波兰语信息) 我的wordpress模板:Savona 我不知道在哪里可以找到文件中的元素来更改它。我从源浏览器上载包含信息的图像: 这是我的post-content.php <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>&
- 翻译按钮阅读更多
- 翻译“无评论”(当0条评论要发布时,显示“无评论”,但当我至少有一条评论时,我有正确的波兰语信息)
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php
if ( have_posts() ) :
// Loop Start
while ( have_posts() ) :
the_post();
?>
<div class="post-media">
<?php the_post_thumbnail('savona-full-thumbnail'); ?>
</div>
<header class="post-header">
<?php
$category_list = get_the_category_list( ', ' );
if ( savona_options( 'single_page_show_categories' ) === true && $category_list ) {
echo '<div class="post-categories">' . ent2ncr($category_list) . ' </div>';
}
?>
<h1 class="post-title"><?php the_title(); ?></h1>
<div class="post-meta clear-fix">
<?php if ( savona_options( 'single_page_show_date' ) === true ) : ?>
<span class="post-date"><?php the_time( get_option( 'date_format' ) ); ?></span>
<?php endif; ?>
</div>
</header>
<div class="post-content">
<?php
// The Post Content
the_content('');
// Post Pagination
$defaults = array(
'before' => '<p class="single-pagination">'. esc_html__( 'Pages:', 'savona' ),
'after' => '</p>'
);
wp_link_pages( $defaults );
?>
</div>
<footer class="post-footer">
<?php if ( savona_options( 'single_page_show_author' ) === true ) : ?>
<span class="post-author"><?php esc_html_e( 'By', 'savona' ); ?> <?php the_author_posts_link(); ?></span>
<?php endif; ?>
<?php
if ( savona_options( 'single_page_show_comments' ) === true && comments_open() ) {
comments_popup_link( esc_html__( 'No Comments', 'savona' ), esc_html__( '1 Comment', 'savona' ), '% '. esc_html__( 'Comments', 'savona' ), 'post-comments');
}
?>
</footer>
<?php
endwhile; // Loop End
endif; // have_posts()
?>
</article>
虽然这可能不是一种正确的方法,但您可以像下面这样轻松地进行更改
“博客页面\u更多\u文本”=>“阅读更多”,
使用'blog\u page\u more\u text'=>'Czytaj dalej',
in
“inc/customizer/customizer defaults.php”'No Comments'
替换为'Brak komentarzy'
我认为,你可以把WordPress的语言改为“Polski”,而不是将文本翻译成波兰语 如果此选项不可用,请检查如何安装新语言。你可以 如果您只想更改当前工作中的翻译文本,可以执行以下操作: 阅读更多信息 要将[…]替换为[Read More]链接,请将其添加到子主题的functions.php中
function new_excerpt_more($more) {
global $post;
return ' <a class="moretag" href="'. get_permalink($post->ID) . '">[Read More]</a>'; //Change to suit your needs
}
add_filter( 'excerpt_more', 'new_excerpt_more' );
function new_excerpt_more($more) {
global $post;
return ' <a class="moretag btn btn-primary" href="'. get_permalink($post->ID) . '">Read More »</a>'; //Change to suit your needs
}
add_filter( 'excerpt_more', 'new_excerpt_more' );
函数新建\u摘录\u更多($更多){
全球$员额;
返回“”;//更改以满足您的需要
}
添加_过滤器('extract_more','new_extract_more');
要将[…]替换为“阅读更多”按钮,请将其添加到子主题的functions.php中
function new_excerpt_more($more) {
global $post;
return ' <a class="moretag" href="'. get_permalink($post->ID) . '">[Read More]</a>'; //Change to suit your needs
}
add_filter( 'excerpt_more', 'new_excerpt_more' );
function new_excerpt_more($more) {
global $post;
return ' <a class="moretag btn btn-primary" href="'. get_permalink($post->ID) . '">Read More »</a>'; //Change to suit your needs
}
add_filter( 'excerpt_more', 'new_excerpt_more' );
函数新建\u摘录\u更多($更多){
全球$员额;
返回“”;//更改以满足您的需要
}
添加_过滤器('extract_more','new_extract_more');
如果您没有子主题,请检查它。
无评论
请再次将以下内容更改为子主题:
这里是存储my child主题和自定义(包括编辑的comments.php文件)的位置public\u html/wp content/themes/your child theme/comments.php
找到并编辑注释文件后,保存它并检查自定义文本
希望这将帮助您在打开body标记后将这些代码放入
header.php
文件中。它将自动将您当前的翻译为波兰语
语言或您希望的提供语言
<div id="google_translate_element"></div>
<script type="text/javascript" src="//translate.google.com/translate_a/element.js?"></script>
<script type="text/javascript">
function googleTranslateElementInit() {
new google.translate.TranslateElement({
pageLanguage: "en",
includedLanguages: "pl",
},'google_translate_element');
}
jQuery(window).on('load',function(){ //console.log('Innnnnn');
googleTranslateElementInit();
setTimeout(function(){
var a = document.querySelector("#google_translate_element select");
//console.log('Hellllo:: ',a);
a.selectedIndex=1;
a.dispatchEvent(new Event('change'));
},4000);
});
</script>
函数googleTranslateElementInit(){
新的google.translate.TranslateElement({
页面语言:“en”,
包括语言:“pl”,
}“谷歌翻译元素”);
}
jQuery(window).on('load',function(){//console.log('innnnn');
googleTranslateElementInit();
setTimeout(函数(){
var a=document.querySelector(“谷歌翻译元素选择”);
//log('helllo::',a);
a、 selectedIndex=1;
a、 调度事件(新事件(“变更”);
},4000);
});
你想更改文本还是翻译文本?这是一个更改和翻译:)我想对“Czytaj dalej”进行“阅读更多”更改,对“Brak komentarzy”进行“无评论”更改。你使用过任何翻译插件吗?我自己没有安装这样的插件,这是在页面加载时应用自动翻译的最佳方式。