sarahjadesigns
Forum Replies Created
-
Forum: Everything else WordPress
In reply to: PHP error after updating PHP versionFinally had the chance to look into this. It wasn’t enough to swap
file_get_contents()
withwp_remote_get()
– this would give an error about the line below withjson_decode()
needing a string.By wrapping
$filecontent
on that line inwp_remote_retrieve_body()
(thanks Google!), the code now works. Full function below.function full_comment_count() { global $post; $url = get_permalink($post->ID); $filecontent = wp_remote_get('https://graph.facebook.com/?ids=' . $url); $json = json_decode(wp_remote_retrieve_body($filecontent)); $count = $json->$url->comments; $wpCount = get_comments_number(); $realCount = $count + $wpCount; if ($realCount == 0 || !isset($realCount)) { $realCount = 0; } return $realCount; }
Forum: Everything else WordPress
In reply to: PHP error after updating PHP versionThanks @ipstenu. My skills with PHP pretty much only extend to be able to tweak things a tiny bit. When it comes to function building, I have a pretty fuzzy understanding.
Comparing your info on
wp_remote_get()
andfile_get_contents()
, I get the sense that the main difference is that the former allows you to fetch an external URL. Could I then just swap it like so?function full_comment_count() { global $post; $url = get_permalink($post->ID); $filecontent = wp_remote_get('https://graph.facebook.com/?ids=' . $url); $json = json_decode($filecontent); $count = $json->$url->comments; $wpCount = get_comments_number(); $realCount = $count + $wpCount; if ($realCount == 0 || !isset($realCount)) { $realCount = 0; } return $realCount; }
Or is there more I need to do with
wp_remote_get()
to get a combined count of Facebook and WordPress comments for a post?Forum: Everything else WordPress
In reply to: PHP error after updating PHP versionLooks like
zlib
was enabled on both with PHP 5.6 and 7.4. I tried switching to version 8.0 to see if whatever issue had been resolved with that one, but that just gives me a big fat WordPress error and the site won’t load at all.I’m completely at a loss for how to fix this. Any other insight would be appreciated.
- This reply was modified 3 years, 6 months ago by sarahjadesigns.
Forum: Everything else WordPress
In reply to: PHP error after updating PHP versionThanks for clarifying. I did have a look at the extensions in my cPanel, but didn’t find anything similar to
zlib
, which is why I thought I maybe had initially misunderstood your link. I’ll get in touch with my host and see if they can help me get to the bottom of this.Forum: Everything else WordPress
In reply to: PHP error after updating PHP versionThanks @joyously, I did read it. However, this bit and the supporting links about fopen wrappers are sort of Greek to me, as I don’t know enough about PHP to code it from scratch. Is the notion that I can just swap out
file_get_contents()
withfopen()
, or is there more I need to do here?Forum: Everything else WordPress
In reply to: PHP error after updating PHP versionI’m not sure what you mean @joyously, the info at the top of the page you linked seems to indicate it works with versions 5, 7 and 8. Even the changelog further down indicates as much.
But if I’m misinterpreting this, then what could I do to replace
file_get_contents()
?Forum: Themes and Templates
In reply to: WordPress 4.4 update broke Tag CloudThis worked great, thanks for the fix!
Forum: Plugins
In reply to: [AJAX Contact] Get user IPI’d like to add that I’ve been able to add a function to my theme which displays the visitor’s IP (see what I used here). This displays the IP when you use the shortcode
[ show_ip ]
. It works on pages and posts without a problem. But I can’t get it to work in the hidden field, either by typing it enclosed in single[ ]
or double[ [ ] ]
square brackets (the forum is doing funny stuff with displaying stuff between square brackets, hope this is clear).Forum: Themes and Templates
In reply to: Inconsistent div width after rotating deviceHmm, couldn’t get it to work with those settings either, weird.
In any case, I managed to fix my issue, so thank you very much ??
Forum: Themes and Templates
In reply to: Inconsistent div width after rotating deviceHello Andrew,
Thanks again. Yes, I did need
overflow: hidden;
but I see now that this is the problem and I can probably work my way around this.I am aware of this feature in Chrome, but when I set the emulation panel to iPhone 5, I did not get this result. It appeared as I want it to be, not how it actually did on my phone. I’ve not found this panel to accurately replicate what I see on my mobile in the past, may I ask what settings you’re using to get this result?
And thank you again for your help.
Forum: Themes and Templates
In reply to: Inconsistent div width after rotating deviceHi Andrew, thanks for catching that. I had a missing
</div>
in the sidebar.Unfortunately this did not fix my problem. All the other flags from the validator are unrelated to this navigation.
Hi Stefanus,
It has been intriguing me why someone would want to add the
title
attribute to an<img>
, so I did a bit of research.First, I want to apologize for my previous comments which dismissed your wanting to use the
title
attribute and saying it is not possible to add it to anything other than links. Somehow in my 15 years of coding HTML, it has completely escaped me that this is an attribute you can add to all visible HTML tags.Still though, I was wondering what the best approach would be for SEO purposes. Should the
title
attribute be added to the<img>
tag, the<a>
tag or both?If you’re wanting your images to come up in Google search results, then use it on your
<img>
tags. If you want to improve your site’s ranking in Google, don’t bother with it on<img>
tags, Google tends to focus on the information in the ALT text. Still though, nice to use it on<a>
tags to get the friendly tooltip. This you can do with Drew’s code above.If you still want to apply the
title
attribute to your<img>
tags for image searches, try the code below based on Drew’s solution. Please note that I’ve not tested this myself.Change line 1860 in
wp-content/plugins/easyrotator-for-wordpress/engine/main.php
from:$codeOut .= '<img class="main" src="' . htmlspecialchars($src) . '"';
to:
$codeOut .= '<img class="main" src="' . htmlspecialchars($src) . '"' title="' . htmlspecialchars($title) . '"';
Hi Stefanus,
I meant what is the result you want on your website? If I go to your site now and hover over your slider, I see specific text for each image. “Modular Buildings”, “Multi House”, etc. This is what my original post was asking how to do, and it seems you’ve been able to do it successfully too.
In HTML, there is no such thing as a
title
attribute on<img>
tags. Even if you added it, it would have no effect, because browsers don’t recognize this as a valid HTML attribute.So what is it you’re trying to change on your site’s slider now?
PS Can you edit your original post so your code is in wrapped in backticks and doesn’t mess with the format of this page?
Hi Stefanus,
Can you clarify what you’re trying to do? The
title
attribute is added to link tags, not image tags. You might be mixing it withalt
attribute that you can add to image tags.What I was wanting to do is add the article’s title as hover text on each slide: https://lucky-stars.ca/ptp
If you go in to edit the plugin file like Drew shows above, you’ll get the same result.
If you want to add the
alt
attribute to your images, that’s a another question altogether ??Forum: Themes and Templates
In reply to: Sidebar disappears from Front Page childrenFound a solution. It doesn’t explain why the problem was happening only on children of the front page, but fixes it nonetheless.
When editing the page, under Sidebar (bottom right), I chose Primary Widget Area from the drop-down, which is the content of my Default template’s sidebar.