我正在研究儿童主题。父主题具有单页模板。安装polylang后,我想覆盖父主题blog-section.php
,因为我需要在其他语言中显示“阅读更多”,例如西班牙语,而不是总是用英语显示。
父主题中的博客PHP是这样的:
layouts->blog-section.php;
blank-section.php;
etc.
我尝试创建一个名为layouts的新文件夹,并将自己的blog-section.php
粘贴到子主题文件夹中。我更改了子主题blog-section.php
中的一些代码。我试了好几次但没有改变。
我从谷歌,关于那些钩子等功能读取,但我不知道在这种情况下如何使用它。我重写了css,并将其他函数添加到我的函数文件中。那些作品。
当模板位于父主题的子文件夹下时,有人可以给我任何关于如何执行此类任务的建议吗?父主题名称是accesspress-parallax。孩子的名字是accesspress-parallax-child。提前感谢您的建议!
父主题主页:
<?php
/**
* Template Name: Home Page
*
* @package accesspress_parallax
*/
get_header();
$sections = of_get_option('parallax_section');
if(!empty($sections)):
foreach ($sections as $section) :
$page = get_post( $section['page'] );
$overlay = $section['overlay'];
$image = $section['image'];
$layout = $section['layout'];
$category = $section['category'];
$googlemapclass = $layout == "googlemap_template" ? " google-map" : "";
?>
<?php if(!empty($section['page'])): ?>
<section class="parallax-section clearfix<?php echo $googlemapclass." ".$layout; ?>" id="<?php echo "section-".$page->ID; ?>">
<?php if(!empty($image) && $overlay!="overlay0") : ?>
<div class="overlay"></div>
<?php endif; ?>
<?php if($layout != "googlemap_template") :?>
<div class="mid-content">
<?php endif; ?>
<?php
$query = new WP_Query( 'page_id='.$section['page'] );
while ( $query->have_posts() ) : $query->the_post();
?>
<?php
if($layout != "action_template" && $layout != "blank_template" && $layout != "googlemap_template"): ?>
<h1><span><?php the_title(); ?></span></h1>
<div class="parallax-content">
<?php if(get_the_content() != "") : ?>
<div class="page-content">
<?php the_content(); ?>
</div>
<?php endif; ?>
</div>
<?php endif; ?>
<?php
endwhile;
?>
<?php
switch ($layout) {
case 'default_template':
$template = "layouts/default";
break;
case 'service_template':
$template = "layouts/service";
break;
case 'team_template':
$template = "layouts/team";
break;
case 'portfolio_template':
$template = "layouts/portfolio";
break;
case 'testimonial_template':
$template = "layouts/testimonial";
break;
case 'action_template':
$template = "layouts/action";
break;
case 'blank_template':
$template = "layouts/blank";
break;
case 'googlemap_template':
$template = "layouts/googlemap";
break;
case 'blog_template':
$template = "layouts/childblog";
break;
default:
$template = "layouts/default";
break;
}
?>
<?php include($template."-section.php");?>
<?php if($layout != "googlemap_template") :?>
</div>
<?php endif; ?>
</section>
<?php
endif;
endforeach;
endif;
?>
<?php get_footer(); ?>
父主题blog-section.php页面: layouts-&GT;博客-section.php:
<?php
/**
* The template for displaying all Parallax Templates.
*
* @package accesspress_parallax
*/
?>
<div class="blog-listing clearfix">
<?php
$args = array(
'cat' => $category,
'posts_per_page' => 3
);
$count_service = 0;
$query = new WP_Query($args);
if($query->have_posts()):
$i = 0;
while($query->have_posts()): $query->the_post();
$i = $i + 0.25;
?>
<a href="<?php the_permalink(); ?>" class="blog-list wow fadeInDown" data-wow-delay="<?php echo $i; ?>s">
<div class="blog-image">
<?php if(has_post_thumbnail()) :
$image = wp_get_attachment_image_src(get_post_thumbnail_id(get_the_ID()),'blog-thumbnail'); ?>
<img src="<?php echo esc_url($image[0]); ?>" alt="<?php the_title(); ?>">
<?php else: ?>
<img src="<?php echo get_template_directory_uri(); ?>/images/no-image.jpg" alt="<?php the_title(); ?>">
<?php endif; ?>
</div>
<div class="blog-excerpt">
<h3><?php the_title(); ?></h3>
<h4 class="posted-date"><i class="fa fa-calendar"></i><?php echo get_the_date(); ?></h4>
<?php echo accesspress_letter_count( get_the_excerpt(), 200 ); ?> <br />
<span><?php _e('**Read more**','accesspress-parallax') ?> <i class="fa fa-angle-right"></i></span>
</div>
</a>
<?php
endwhile;
wp_reset_postdata();
endif;
?>
</div>
<div class="clearfix btn-wrap">
<a class="btn" href="<?php echo get_category_link($category)?>"><?php _e('Read more','accesspress-parallax'); ?></a>
</div>