adapting post-content-container render to handle inner render.php
This commit is contained in:
parent
78d9480dca
commit
d89e334aa3
File diff suppressed because one or more lines are too long
|
|
@ -2,10 +2,24 @@
|
|||
$relatedPostId = $attributes['relatedPostId'] ?? null;
|
||||
$relatedPost = get_post($relatedPostId);
|
||||
$anchor = isset($attributes['anchor']) ? esc_html($attributes['anchor']) : "post-content-container-" . $relatedPostId;
|
||||
$content = get_the_content(null, null, $relatedPost);
|
||||
|
||||
|
||||
if ($relatedPost) {
|
||||
// Temporarily set up the global post variable so the_content works as expected
|
||||
global $post;
|
||||
$post = $relatedPost;
|
||||
setup_postdata($post);
|
||||
|
||||
ob_start();
|
||||
the_content();
|
||||
$content = ob_get_clean();
|
||||
wp_reset_postdata();
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
<section id="<?php echo $anchor ?>" class="post-content-container <?php echo $anchor ? "has-custom-anchor" : "" ?>">
|
||||
<h2 class="post-content-container__title"><?php echo $relatedPost->post_title ?></h2>
|
||||
<?php echo $relatedPost->post_content ?>
|
||||
<?php echo $content; ?>
|
||||
</section>
|
||||
|
|
@ -2,10 +2,24 @@
|
|||
$relatedPostId = $attributes['relatedPostId'] ?? null;
|
||||
$relatedPost = get_post($relatedPostId);
|
||||
$anchor = isset($attributes['anchor']) ? esc_html($attributes['anchor']) : "post-content-container-" . $relatedPostId;
|
||||
$content = get_the_content(null, null, $relatedPost);
|
||||
|
||||
|
||||
if ($relatedPost) {
|
||||
// Temporarily set up the global post variable so the_content works as expected
|
||||
global $post;
|
||||
$post = $relatedPost;
|
||||
setup_postdata($post);
|
||||
|
||||
ob_start();
|
||||
the_content();
|
||||
$content = ob_get_clean();
|
||||
wp_reset_postdata();
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
<section id="<?php echo $anchor ?>" class="post-content-container <?php echo $anchor ? "has-custom-anchor" : "" ?>">
|
||||
<h2 class="post-content-container__title"><?php echo $relatedPost->post_title ?></h2>
|
||||
<?php echo $relatedPost->post_content ?>
|
||||
<?php echo $content; ?>
|
||||
</section>
|
||||
Loading…
Reference in New Issue
Block a user