janew
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: link only images that are biggerFair enough, but I want it to link only when the original image is larger than the “Large” size set in Media settings. Maybe that part is mixing things up.
I guess I should be asking for it to link images if the original image is wider than the max content-width. In that regard, nothing changes from browser to browser. Whether the viewport is 240px or 2400px, the content-width is always limited to 800px, and therefore the largest the image can be displayed is 800px. And I want to link to images that are larger than that.
It’s my understanding that WordPress “knows” how big the original image is, so it can know if it is bigger than the max content-width and if it should link to it or not.
I just don’t have any idea how to tell it to do so, in functions.php. Or if it’s even possible.
Forum: Fixing WordPress
In reply to: link only images that are biggerI don’t understand. At the time of linking, the following code is inserted into the post:
<a href="https://www.foo.com/wp-content/uploads/2020/12/image.jpg"><img src="https://www.foo.com/wp-content/uploads/2020/12/image-800x1159.jpg" alt="" width="800" height="1159" class="alignnone size-large wp-image-1346" /></a>
Regardless of device, the image loaded has the size appended: 800×1159 – which means the original is larger than the image displayed and can be linked to. If there is no size appended to the image, then it is already showing the original and does not need to be linked.
So even if the user is viewing on a phone with a 240px width, it is still showing the image with the 800×1159 size, just showing it smaller, so it fits on the device screen. But the picture itself is still 800px wide. Right?
If I’m wrong, please explain, because that is how I understand this to work.
With regard to content-width, I have already re-defined that to 800px, so there is no issue with that ever overriding my Media settings.
Thanks!
Forum: Themes and Templates
In reply to: [Twenty Twenty] Navigate within same categoryNevermind! lol
That *does* work – I was just testing it on the wrong page! ??
For an even shorter version, do this:
$next_post = get_next_post(true);
$prev_post = get_previous_post(true);Posting in case it helps someone else.
Thanks!
Forum: Themes and Templates
In reply to: [Twenty Twenty] Navigate within same categoryI am trying to avoid using plugins as much as possible.
Why doesn’t this work:
$next_post = get_next_post($in_same_term = true, $excluded_terms = '', $taxonomy = 'category'); $prev_post = get_previous_post($in_same_term = true, $excluded_terms = '', $taxonomy = 'category');
Forum: Fixing WordPress
In reply to: adding date/time to tooltipSorry didn’t mean to imply that you were giving styling advice … everything I googled wanted to tell me how to style it and I didn’t want you to waste your time explaining all that in case that’s what you thought I was looking for, since you said you didn’t understand.
Anyway, the code you provided is a good starting point, and I was able to “fix” it to my needs.
First off, I figured out the
$
lines need to go before theif
statement. And in the span the first php should read$dateis
. I thought puttingecho
beforethe_title
might screw it up, but it did not – but neither did removing it altogether. So I guess it’s unnecessary, sometimes….
Once I got that fixed there was one other major problem: it was only showing the current date and time, and changed on every reload. Some digging – and trial and error – had me realizing that the$
lines needed to read as$dateis=get_the_date(); $timeis=get_the_time();
Once I did that, the post date was then showing in the tool tip, as I want.
So thank you for putting me on the right track!
Forum: Fixing WordPress
In reply to: adding date/time to tooltip@corrinarusso Yes that’s a form of tool tip, though styled a bit, I guess. I’m not looking for styling advice though, just want to make it work using the html title attribute.
https://ibb.co/PF7MdnnForum: Fixing WordPress
In reply to: Show one post from certain categoryThat’s it!
After this code in the original, there is a bunch of mixed html/php that I didn’t need, followed by the usualget_footer();
, so I completely missed theendwhile;
that was buried in between. And since it wasn’t in the code I was replacing, I didn’t even think about it.Thank you for explaining that the colon replaces the opening brace – I wasn’t aware of that, and now it makes more sense as I never really understood why
endwhile;
would only show up sometimes.Thank you so much!
Forum: Plugins
In reply to: [Jetpack - WP Security, Backup, Speed, & Growth] Error and WarningOriginal post error message copied from Chrome. This is Firefox:
Uncaught SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data onload jQuery send https://widgets.wp.com/likes/master.html?ver=202052#ver=202052&lang=en-ca:1 jQuery 7 displayWidget ajax success makeProxyCall execute resolve receive
Forum: Themes and Templates
In reply to: [Twenty Twenty] renovate comments sectionNevermind! lol
I have found workarounds and a great code from @alexmoise (referenced in link above), to which I added the ‘cookies’ field. This is the full, slightly modified code:
// comment form fields re-defined: add_filter( 'comment_form_default_fields', 'mo_comment_fields_custom_html' ); function mo_comment_fields_custom_html( $fields ) { // first unset the existing fields: unset( $fields['comment'] ); unset( $fields['author'] ); unset( $fields['email'] ); unset( $fields['url'] ); unset( $fields['cookies'] ); // then re-define them as needed: $fields = [ 'comment_field' => '<p class="comment-form-comment"><label for="comment">' . _x( 'A CUSTOM COMMENT LABEL', 'noun', 'textdomain' ) . '</label> ' . '<textarea id="comment" name="comment" cols="45" rows="8" maxlength="65525" aria-required="true" required="required"></textarea></p>', 'author' => '<p class="comment-form-author">' . '<label for="author">' . __( 'A CUSTOM NAME LABEL', 'textdomain' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' . '<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30" maxlength="245"' . $aria_req . $html_req . ' /></p>', 'email' => '<p class="comment-form-email"><label for="email">' . __( 'A CUSTOM EMAIL LABEL', 'textdomain' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' . '<input id="email" name="email" ' . ( $html5 ? 'type="email"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30" maxlength="100" aria-describedby="email-notes"' . $aria_req . $html_req . ' /></p>', 'cookies' => '<p class="comment-form-cookies-consent"><input id="wp-comment-cookies-consent" name="wp-comment-cookies-consent" type="checkbox" value="yes" /> <label for="wp-comment-cookies-consent">Save my name and email in this browser for the next time I comment.</label></p>', 'url' => '<p class="comment-form-url"><label for="url">' . __( 'A CUSTOM WEBSITE LABEL', 'textdomain' ) . '</label> ' . '<input id="url" name="url" ' . ( $html5 ? 'type="url"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" maxlength="200" /></p>', ]; // done customizing, now return the fields: return $fields; } // remove default comment form so it won't appear twice; leave it if user is already logged in add_filter( 'comment_form_defaults', 'mo_remove_default_comment_field', 10, 1 ); function mo_remove_default_comment_field( $defaults ) { if ( !is_user_logged_in() ) { if ( isset( $defaults[ 'comment_field' ] ) ) { $defaults[ 'comment_field' ] = ''; } } return $defaults; }
I used css to hide the display of the comment-notes section and simply added “(will not be published)” note after the Email label. Hiding Website field makes all fields required and, though I didn’t figure out a way to add an “all fields required” notice (it’s probably simple but I’m sick of dealing with this so not even gonna try) I think it’s implied.
Hope this helps someone else! All credit to @alexmoise!
Forum: Fixing WordPress
In reply to: Resetting comment field in code@alexmoise That’s perfect!
I was sooo close to figuring this out. lol
I figured it had to be this way but couldn’t think how to write
is_user_not_logged_in
, and totally forgot about the ! – I can understand it when it shows up in code I am reading, but I can never remember those symbols to write them.So everything is how I envisioned, except I think I would have made the mistake of leaving the last line
return $defaults
within the isset area – which is to say I would have had two braces after that line instead of one.So thank you very much for this, and for the rest of the code that it belongs to. It’s all super fantastic. I wish WordPress was easier to customize in this way, but maybe it just isn’t possible.
Thank you!
Forum: Plugins
In reply to: [Jetpack - WP Security, Backup, Speed, & Growth] Error and WarningYes, fully up to date WordPress and Jetpack. Error and Warning both occur with all other plugins disabled. Running TwentyTwenty with a child theme. Shows on Post not on Page.
Sorry, can’t share the link.Forum: Fixing WordPress
In reply to: Change “Comments” form (bis)Hi @alexmoise I am also using this excellent code you provided on another thread. That topic is closed, so I am adding to this one, which is wrong but still related so hopefully I don’t get in trouble!
So, at the bottom of this code is a function to remove the default comment field so it won’t appear twice. Unfortunately the result of this is that, while people not logged in will see my form as I want it to be seen, people already logged in see no comment area to fill in.
How can I set that last bit to only suppress the default if someone is *not* logged in?
Thanks!
- This reply was modified 4 years, 2 months ago by janew.
Forum: Fixing WordPress
In reply to: renovate comments area part 2Done, thanks!
Forum: Fixing WordPress
In reply to: renovate comments area part 2@t-p
Are these not all WordPress things?
These are all changes to the comment_form which comes from wp-includes, not the theme. None of it is theme-specific. Is it?
And it’s twentytwenty theme, which is generated by WordPress as well, sooo…. ???♀?Happy to take it elsewhere, just seems like this is the best place to get the answers I’m looking for. Let me know if I’m wrong.
Forum: Fixing WordPress
In reply to: renovate comments area part 2Add: In case it’s a concern, I am removing the url field entirely from the comments form
p.comment-form-url {display: none; }
So requiring all fields is just requiring name and email.
Thanks!