Plugin Author
Mike
(@mgsisk)
Hey Hannah! It looks like you’re using the shortcodes correctly; I’m pretty sure Webcomic is at fault. The problem (with your [previous_webcomic_link]
example, at least) is the in_same_term
argument. Webcomic is expecting a strict boolean value of true
, but – when used as a shortcode – it’s actually getting a string “true”, which it misinterprets as something else.
I probably won’t be able to release a proper Webcomic update until October, so here’s the fix (if you’re adventurous): open up /webcomic/-/php/tags.php and find this block of code inside the public static function get_relative_webcomic
function (it starts on line 724 in my dev copy):
if ( ( $in_same_term or $excluded_terms ) and $taxonomy ) {
$join = " INNER JOIN {$wpdb->term_relationships} AS tr ON p.ID = tr.object_id INNER JOIN {$wpdb->term_taxonomy} tt ON tr.term_taxonomy_id = tt.term_taxonomy_id";
$exclude = " AND tt.taxonomy IN ( '" . implode( "', '", $taxonomy ) . "' )";
if ( true === $in_same_term and $post_id ) {
$include = wp_get_object_terms( $post_id, $taxonomy, array( 'fields' => 'ids' ) );
} elseif ( $in_same_term and true !== $in_same_term ) {
$include = is_array( $in_same_term ) ? array_map( 'intval', $in_same_term ) : array_map( 'intval', explode( ',', $in_same_term ) );
} else {
$include = array();
}
…
Just below the $exclude = …
line, add this:
$in_same_term = 'true' === $in_same_term ? true : $in_same_term;
That should correct the issue for this shortcode. Are you having issues with any other shortcodes?
Hi Mike,
That’s great, many thanks! I’m relatively confident with editing core files, including php files, so I’ll give this a try 🙂
This is the only thing I’ve found that isn’t working as I expected – everything else seems to be working like a charm.
Cheers!
Hannah
This worked perfectly, thanks for your help!