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

[question] How can I use a query to show character names? #350

Closed j2franklin closed 2 years ago

j2franklin commented 4 years ago

Hello

I'm using some data from the webcomic for my wordpress theme. I had a hard time finding a way to build a wp_query to use the data, but I found a post on the internet that showed you how to use data from collections:

$comics = new WP_Query( [ 'order' => 'DESC', 'post_type' => get_webcomic_collections(), // Or specify a collection ID, like 'webcomic42' 'tag_id' => 20, 'posts_per_page' => 3, ] );

It worked. So I tried to do the same for the characters using get_webcomic_characters (), but it didn't work. I used an IF / ELSE to return "no records" if the query found no data, but the code found data even though it doesn't show anything.

<?php $char = new WP_Query( [ 'order' => 'DESC', 'post_type' => ##get_webcomic_characters(), 'posts_per_page' => 4, ] );

I use echo webcomic_character_count () and the return is 0. But there are 2 registered characters. And I believe the code knows why the IF returns true. What am I doing wrong? I just need the character's name and the image. I'm still new to wordpress and don't have much experience with plugins. I appreciate any help.