• Resolved faranae

    (@faranae)


    Me again! Separate topic so as not to mess with the search should anyone else have this question.

    I currently have my characters displaying on a cast page using the [webcomic_characters_list] shortcode around a table so that I can easily format for this page specifically in my CSS:

    [webcomic_characters_list hide_empty="true"]
    <table class="castpagegrid"><tbody>
    <tr><td>%thumbnail</td></tr>
    <tr><td>%title</td></tr>
    </tbody></table>
    [/webcomic_characters_list] 

    It works beautifully (image via imgur) to format for my needs! However, this becomes complicated should I introduce any sort of character taxonomic hierarchy.

    SIDE QUESTION:

    With a taxonomy set up, any character list dropdown displays perfectly as expected. (image via imgur) However, I’ve not yet figured out how to set the default text to something like “Select a Character” as it does in a widget display. I have the shortcode filled out as such: [webcomic_characters_list format="<select>{{join}}</select>"][/webcomic_characters_list] If it isn’t possible to give the dropdown a default text outside of the widget that’s fine. This is more a side thing.

    PRIMARY QUESTION:

    When there is a hierarchy in place for characters, in my visual/grid display each parent is given its own entry even if hide_empty is set to “true”. (image via imgur) I assume this is because they technically have children even if no pages are directly assigned to them?

    I’d like to work around this by potentially making a new page that manually organizes the parents as headings, and calls ONLY the involved children/characters using a shortcode beneath them, but I’ve had no luck with the link method we discussed in my previous thread. I also tried using the taxonomy argument but I feel I might be using it incorrectly? I’ve tried entering the parent’s name, slug, and ID as a parameter but none of them seem to change the output. Here’s a mockup of what I’d like to accomplish if possible, I know my wording can be terrible at times for getting ideas across: (image via imgur)

    Is there an argument I’m misreading/not understanding correctly that might allow me to list characters only beneath a certain hierarchical level?

    Thank you once again, so very much, for the assistance. There’s only so far a novice background in C and CSS can take me here but I’m trying my very best to troubleshoot without bothering you. ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Mike

    (@mgsisk)

    PRIMARY QUESTION

    That’s correct; even though the parent may not have any posts assigned to it, WordPress doesn’t consider it truly “empty” if any of it’s children have a post assigned. To get just a parent’s children, what you really want is a parent argument.

    The bad news is that Webcomic doesn’t currently support parent as an attribute for the webcomic_characters_list shortcode (short reason: WordPress makes you specify each attribute a shortcode supports, and parent just didn’t make the cut).

    The good news is that you don’t have to wait for me to add support for parent; you can do it yourself by pasting this code into your theme’s functions.php file:

    
    function shortcode_atts_webcomic_terms_list_custom( $out, $pair, $atts, $shortcode ) {
    	if ( isset( $atts['parent'] ) ) {
    		$out['parent'] = (int) $atts['parent'];
    	}
    
    	return $out;
    }
    
    // NOTE: You'll need an add_filter call for each shortcode you want to add parent to.
    // You can use the same callback for all of them; only the filter name would change.
    add_filter( 'shortcode_atts_webcomic_characters_list', 'shortcode_atts_webcomic_terms_list_custom', 10, 4 );
    

    With that in your theme’s functions.php file, you should be able to add a parent property to the webcomic_character_list, like parent="###".

    SECONDARY QUESTION

    Actually, the widget just hardcodes the default option, which is what you should also do in the shortcode:

    
    [webcomic_characters_list format="<select><option value=''>Select a Character</option>{{}}</select>"][/webcomic_characters_list]
    

    Note the use of ' for the value attribute; trying to use " will break the shortcode (since we’re already useing " for the shortcode attribute). Also, you should only put text between the {{ and }} if you want that text to show up between the terms; otherwise, you can leave it blank (<select>‘s ignore this text anyway, so it’s not a big deal here).

    Thread Starter faranae

    (@faranae)

    You’ve gone above and beyond in two instances now, and that means so much. The code was easy to slip into the functions.php and modify as needed for the storylines list as well. This opens several design opportunities for our project! Thank you~!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Character list behaviour when hierarchical, shortcode to call only children?’ is closed to new replies.