Open ehanby opened 7 years ago
inkblot_page_description
is defined in inkblot/_/php/tags.php
; it attempts to get a page-specific description by first grabbing the site description (the tagline defined on the Settings > General screen), and then checking the following:
A fix in this case might be to remove the has_excerpt()
check, which only returns true if an explicit excerpt was written. Changing line 32 in inkblot/_/php/tags.php
:
if (is_singular() and has_excerpt() and ! is_home()) {
to
if (is_singular() and ! is_home()) {
might be enough.
Webcomic should automatically add OpenGraph <meta>
tags to any page associated with a comic collection, including og:image
tags that point to any comic media associated with the current comic page.
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 inkblot_page_description
still isn't returning anything for individual pages or for the home page. I have a blog description in place, and that doesn't show up on the home page as it's meta description either. I made the change you suggested in tags.php and that has not changed the output either. All I get is the static text I inserted before your <?php inkblot_page_description(); ?>
. I took my static text out and the meta description returns blank on all pages. Prior to this I've never even touched tags.php (didn't even know it was there) so I don't know how or why this isn't working.
I also had no opengraph meta tags. There was basically no meta at all. I had to manually put everything in.
For inkblot_page_description
, it looks like the issue is an oversight on my part. Changing line 79 in inkblot/functions.php
from:
<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 inkblot_page_description
just returns the description. Inkblot is due for a rewrite anyway, so I'll add this to the list.
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 Prior to this twitter returned an error with the card validator which is what tipped me off about the meta information to begin with.
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 <meta>
tags you might expect to find.
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 <meta>
tags on the homepage). Let me think about this one; there's one way I can imagine it working, but it would require some code I'll need to put together.
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 functions.php
file:
/**
* 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 og:title
tag.
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.