mgsisk / webcomic

Comic publishing power for the web. Turn your WordPress-powered site into a comic publishing platform with Webcomic.
http://wordpress.org/plugins/webcomic
GNU General Public License v2.0
110 stars 29 forks source link

"get_relative_webcomic_term_link" doesn't work for the "previous" option #253

Closed eh-jogos closed 6 years ago

eh-jogos commented 9 years ago

Hello Mgsisk! Thank you very much for this awesome plugin and awesome support!

Thanks to it I've been succesfuly maintaining a webcomic series for over two years at reddoorhqs.com (only in portuguese unfortunatly) And this year I was able to make a child theme from Twenty-Twelve while integrating it to the webcomics plugin!

I've been building a child theme of twenty-fifteen for another comic project while integrating it to the webcomics plugin as well. The Twenty fifteen theme has a reallly nice navigation between posts, which automatically uses the featured image of the post as th background of the button, and I thought of adding it to webcomic's character and storyline archives.

Unfortunately, I couldn't use the template tags "next_webcomic_storyline_link" or "previous_webcomic_character_link" because they come with they come complete with the "" tag, and I needed to get only the url, as I would be getting the name of the storyline or character, and their featured images separately, so it would integrate better in the style of twenty-fifteen.

So the solution I found was to use "WebcomicTag::get_relative_webcomic_term_link()", besides a lot of other work to get the storylines objects, images, and other properties whenever I needed them.

Everything worked fine except for the previous option. Whenever I try to use "WebcomicTag::get_relative_webcomic_term_link("archive","previous","character")" or WebcomicTag::get_relative_webcomic_term_link("archive","previous","storyline"), it only links to the current archive.

I tried to take a look at the code and I couldn't uderstand it very well, but it seemed that somewhere along it's "ifs" that function called another one and it was "get_relative_webcomic_term". And this is where it gets interesting:

On line 1158 of tags.php , inside "get_relative_webcomic_term" I found this:

if ( !taxonomy_exists( $taxonomy ) and WebcomicTag::is_webcomic_tax() ) {
            $taxonomy = $object->taxonomy;
        } elseif ( ( 'next' === $relative or 'previous' === $relative ) and is_singular() and $terms = wp_get_object_terms( $post->ID, $taxonomy, array_merge( array( 'hide_empty' => true, 'orderby' => is_taxonomy_hierarchical( $taxonomy ) ? 'term_group' : 'name' ), ( array ) $args, array( 'cache_domain' => 'get_relative_webcomic_term' ) ) ) and !is_wp_error( $terms ) ) {
            $object = 'next' === $relative ? array_pop( $terms ) : array_shift( $terms );
        }

I noticed that the else if statement says both "next" and "previous" but only "next" has a definition of how it should work, there's nothing there for the "previous" case. I don't know it that's the problem but maybe it helps!

Anyway, I was able to get what I wanted working by using a crude solution:

<a href="<?php  echo home_url()."/oeste-selvagem-character/".$characterObj[$previous_char]->slug ; ?>" rel="prev">

But I'd gladly get rid of it once the proper webcomic tag is working =D