-
-
Notifications
You must be signed in to change notification settings - Fork 11
inkblot_page_description() not returning any data #64
Comments
A fix in this case might be to remove the if (is_singular() and has_excerpt() and ! is_home()) { to if (is_singular() and ! is_home()) { might be enough. Webcomic should automatically add OpenGraph |
I tested the excerpt function by putting in an excerpt. Apparently I tried doing this a week ago too, and left the except there for that page, but I also had no opengraph meta tags. There was basically no meta at all. I had to manually put everything in. |
For <meta name="description" content="<?php inkblot_page_description(); ?>"> to <meta name="description" content="<?php echo inkblot_page_description(); ?>"> should get the description showing. The problem – upon closer inspection – is that I'm not aware of any issues with Webcomic's meta data output, unfortunately. If you can provide an example URL I might be able to get an idea of what's going on with that. |
Thank you, That change to functions.php fixed the issue, and now it displays the excerpt field/blog information as the meta description. I feel like I might have been able to pick up on the echo thing if I had only thought about it more, but I'm not a coder outside of CSS so I didn't think about it. I have gone ahead and taken out all the manual information I put in for the other meta tags, so that I've returned the code back to what I had before. That way you can see clearly what might be going on. The website is http://whitewatercomic.com |
No worries, @ehanby; it's been two years since I originally coded the thing and I didn't even notice until just now. 😅 Thanks for the link. What's happening isn't so much a bug as a nuance of how Webcomic works. To determine what meta data to add to a page – or wether it should add any meta data to a page at all – Webcomic first checks to see if the page is related to a specific collection. This work for most pages; if you look at the source for http://whitewatercomic.com/comic/30, for example, you'll see that it's adding all the The standard WordPress homepage is an unfortunately-unique case in that Webcomic can't know what collection it belongs to, as the homepage isn't really a "page" in the sense that there's a specific post associated with it. There are some potential work-arounds for this, but I don't think any would do exactly what you're looking for (e.g. getting all of the appropriate comic info into |
Ok, thank you very much! You're right, the individual pages are returning opengraph data and I hadn't even noticed. Overall I'm satisfied that this issue is fixed to the best of its ability for the moment. I guess while I have your attention I'll just ask about one nitpick. I like for it to say "Page 30" underneath the comic, but on the archive page to just say "30" so I worked my way around this by making the individual comic page named just "30" and appending "Page" in plaintext before that part in the title underneath the comic. This works great, though it means that the og:title is just "30" as well. Any way to append a plaintext "Page" there for now, or is that just a dream? Alternatively I am happy with a solution that somehow strips "Page " from the title of every comic on the archive page, and I go back and change every page title. |
I don't know that there's a best way to do this, but there's an OpenGraph filter in Webcomic 4 that'll let you do this. Adding this to Inkblot's /**
* Prepend 'Page ' to every comic title for OpenGraph data.
*
* @param array $data The OpenGraph data to filter.
* @return array
*/
function filter_webcomic_opengraph( $data ) {
// Abort if there's no title or this isn't a comic post.
if ( empty( $data[ 'og:title' ] ) || ! is_webcomic() ) {
return $data;
}
$data[ 'og:title' ] = 'Page ' . $data[ 'og:title' ];
return $data;
}
add_filter( 'webcomic_opengraph', 'filter_webcomic_opengraph' ); should prepend "Page " to all of your comic titles for the As a heads up, this solution won't work in the hopefully-soon-to-be-released Webcomic 5. You'll need to change it slightly to: /**
* Prepend 'Page ' to every comic title for Twitter Card data.
*
* @param array $data The Twitter card data to filter.
* @return array
*/
function filter_webcomic_twitter_card( $data ) {
// Abort if there's no title or this isn't a comic post.
if ( empty( $data[ 'title' ] ) || ! is_webcomic() ) {
return $data;
}
$data[ 'title' ] = 'Page ' . $data[ 'title' ];
return $data;
}
add_filter( 'webcomic_twitter_card_data', 'filter_webcomic_twitter_card' ); |
I was looking into why there is no metadata for anything to pull from - twitter didn't generate a card, facebook didn't find the blog description - and in the process realized inkblot_page_description() was not creating any data. I noticed in the html it was coming up:
<meta
name="description"content="">
and noticed in functions.php it only had inkblot_page_description()I can't figure out where this php function is trying to pull from, but looking at the individual posts in wordpress there doesn't seem to be any custom "description" box I should be inputting text in. I already type some words into the main post box every time I post a comic but obviously those aren't being pulled. So I'm at a loss as to why this function is included if it goes nowhere. For the time being I've put in a static metadata description there with the php function hanging off the end - if it doesn't work now, maybe one day it will.
As a side note, I put in a static image for the twitter card too, but obviously I would prefer it be whatever comic image was on the page at the time, but I can't figure out what php code would make that happen.
The text was updated successfully, but these errors were encountered: