handling empty relatedPostID
This commit is contained in:
parent
915f0aca68
commit
9b451fbaf3
|
|
@ -1,9 +1,13 @@
|
||||||
<?php
|
<?php
|
||||||
$relatedPostId = $attributes['relatedPostId'] ?? null;
|
|
||||||
$relatedPost = get_post($relatedPostId);
|
|
||||||
$anchor = !empty($attributes['anchor']) ? esc_html($attributes['anchor']) : "post-content-container-" . $attributes['relatedPostId'];
|
|
||||||
$content = get_the_content(null, null, $relatedPost);
|
|
||||||
|
|
||||||
|
$relatedPostId = isset($attributes['relatedPostId']) ? $attributes['relatedPostId'] : null;
|
||||||
|
if (!$relatedPostId) return;
|
||||||
|
|
||||||
|
$relatedPost = get_post($relatedPostId) ?? null;
|
||||||
|
$anchor = isset($attributes['anchor']) && !empty($attributes['anchor']) ? esc_html($attributes['anchor']) : "post-content-container-" . $attributes['relatedPostId'];
|
||||||
|
|
||||||
|
$anchor = isset($attributes['anchor']) && !empty($attributes['anchor']) ? esc_html($attributes['anchor']) : ($relatedPostId ? "post-content-container-" . $relatedPostId : '');
|
||||||
|
$content = get_the_content(null, null, $relatedPost);
|
||||||
|
|
||||||
if ($relatedPost) {
|
if ($relatedPost) {
|
||||||
// Temporarily set up the global post variable so the_content works as expected
|
// Temporarily set up the global post variable so the_content works as expected
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,13 @@
|
||||||
<?php
|
<?php
|
||||||
$relatedPostId = $attributes['relatedPostId'] ?? null;
|
|
||||||
$relatedPost = get_post($relatedPostId);
|
|
||||||
$anchor = !empty($attributes['anchor']) ? esc_html($attributes['anchor']) : "post-content-container-" . $attributes['relatedPostId'];
|
|
||||||
$content = get_the_content(null, null, $relatedPost);
|
|
||||||
|
|
||||||
|
$relatedPostId = isset($attributes['relatedPostId']) ? $attributes['relatedPostId'] : null;
|
||||||
|
if (!$relatedPostId) return;
|
||||||
|
|
||||||
|
$relatedPost = get_post($relatedPostId) ?? null;
|
||||||
|
$anchor = isset($attributes['anchor']) && !empty($attributes['anchor']) ? esc_html($attributes['anchor']) : "post-content-container-" . $attributes['relatedPostId'];
|
||||||
|
|
||||||
|
$anchor = isset($attributes['anchor']) && !empty($attributes['anchor']) ? esc_html($attributes['anchor']) : ($relatedPostId ? "post-content-container-" . $relatedPostId : '');
|
||||||
|
$content = get_the_content(null, null, $relatedPost);
|
||||||
|
|
||||||
if ($relatedPost) {
|
if ($relatedPost) {
|
||||||
// Temporarily set up the global post variable so the_content works as expected
|
// Temporarily set up the global post variable so the_content works as expected
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user