hellodrifter
Forum Replies Created
-
Forum: Themes and Templates
In reply to: Conditional Statements for Comments Loop/Loop StructureOkay, never-mind my ramblings. I’ve found out that what I am referring to (using a foreach loop for outputting comments) is the pre-2.7 way of making a comments template, so it’s obsolete. I’ll leave an explanation in case anyone else has the same question.
What I need is not a traditional comments loop, but to edit the way comments are output by
<?php wp_list_comments(); ?>
.If you want to drastically alter the output structure of your comments like me, this is achieved through use of the callback feature of list comments.
So just throw this line of code down
<?php wp_list_comments('callback=custom_comment'); ?>
in comments.php and then, in your functions.php template, define your own custom function, in this case, named ‘custom_comment’. Your custom function will control the way comments are structured. There are examples in the codex and elsewhere so I’ll leave you to search. Goodluck!Forum: Themes and Templates
In reply to: php comment_form. Where do I place the code to remove a field?Thx again esmi, my comment form is coming along great. I found your functions file very helpful in figuring out php syntax and writing my code. When I place the comment_args array and filters inside functions.php, the default form appears in my single post view. But the array works just fine when I place the it above the comment_form function in comments.php. Is there a downside to keeping the array in comments.php rather than functions.php?
Forum: Themes and Templates
In reply to: How to remove the comment_form's 'title_reply' field?Hey, I figured out what I was doing wrong. Two things.
First, the title_reply field needs parentheses around the single quote marks.
'title_reply' => ( '' ),
instead of
'title_reply' => '',
Second, I placed title_reply in the wrong array. My code has two arrays, one nested within the other. The inner array with the comment_form_default_fields hook seems to be specific to the email, author and url fields. Whereas my first array, with no hook, seems to effect the rest of the comment_form defaults without a hiccup.
Here’s the working code.
<?php $comment_args = array( 'fields' => apply_filters( 'comment_form_default_fields', array( 'email' => more code..., 'author' => more code..., 'url' => '' ) ), <!-- close apply_filters and second array --> 'comment_field' => more code..., 'comment_notes_after' => '', 'title_reply' => ( '' ), ); ?> <?php comment_form($comment_args); ?>
Please correct me if my explanation is wrong. Here’s a few tutorials and resources I found helpful.
https://ottopress.com/2010/wordpress-3-0-theme-tip-the-comment-form/
https://www.php.net/manual/en/language.types.array.php
https://devpress.com/blog/using-the-wordpress-comment-form/Forum: Themes and Templates
In reply to: "=>" What does this PHP operator do!?Nevermind, seems it’s not an operator so much as it is an inherent part of an array. It is the part which associates a key with a value within a PHP array, please correct me if I’m wrong.
https://php.net/manual/en/language.types.array.phpLooks like I have a lot of reading ahead of me.
Forum: Themes and Templates
In reply to: php comment_form. Where do I place the code to remove a field?Thank you esmi, I will move forward coding on that basis and post my results.
Forum: Fixing WordPress
In reply to: Extra characters placed on the end of my permalink?Thanks very much for your advice esmi, I’ll play around with your suggestion. ??
Forum: Fixing WordPress
In reply to: Extra characters placed on the end of my permalink?Thank you for your timely response esmi.
Ah I see, so its function is similar to an internal bookmark anchor in HTML.
e.g. <a name="Ambient Mixes">Ambient Mixes</a>
I am glad that lovely functionality is included in the more tag, but in the process it’s still adding rubbish to the end of my url. Now, to find a plugin or other method to take out the trash, while keeping that nice functionality.
Thank you for the link, I hope to find my answer there.
Forum: Themes and Templates
In reply to: blog template will not output static htmlNah, I can’t say I did. I understand that the forum has rules and I don’t have a problem abiding by them. My bad for posting over 10 lines of code.
I must admit though, I found it delightfully ironic that my code was removed right around the time I discovered that the solution to my quandary had nothing to do with the code snippet in question. ??
Forum: Themes and Templates
In reply to: blog template will not output static htmlIt’s just as well that an unhelpful moderator came around and deleted my code snippet without warning. Turns out that after I changed the template name from “page-389.php” to “home.php”, something I had already done a half dozen times before without results, it suddenly begins to output my html code properly. Thus, the snippet is irrelevant.
As to why it did not output my html code the preceding half dozen times I changed the template file name to home.php is beyond me. I admit I am not particularly bright, and my conceptual understanding of wordpress is lacking at best, but this is not the first fix I’ve stumbled across that has appeared entirely random.
Conclusion: I have no idea why my template was not working before, and I have no idea why it is working now. My best guess is that I had buggered up the template hierarchy.
My website is small, clocking in at only 32 pages. I can’t see that number surpassing 50 anytime in the foreseeable future. As such, I may do away with parent child relationships altogether to fix this problem.
Non-numeric, client friendly urls are of the utmost importance for this particular website. That said, I understand (thanks to esmi) the danger my permalink structure poses to site performance. Otto has done a great job of explaining the danger in layman’s terms.
https://ottopress.com/2010/category-in-permalinks-considered-harmful/
Seems using only %postname% for my permalinks will put undue strain onto the database (due to verbose page rules), and could cause serious performance issues if the website expands beyond 50, and into the hundreds of pages range.
My question then, is there any work around to avoid triggering verbose page rules, while also allowing clients to navigate to a particular page via a non-numeric URL? Perhaps a plugin that would allow me to use a database friendly permalink structure (e.g. /yyyy/mm/dd/postname/), that redirects clients who enter a human frienly URL (e.g. /postname/)?
Any thoughts?
Thanks for your fast response esmi!
I’ll go do some further reading on permalink structures, play around and get back to you with my findings. After reading the codex for a few minutes I’ve already come across this strong warning:
Starting Permalinks with %postname% is strongly not recommended for performance reasons.
The only caveat I have is that I need human friendly permalinks like in my previous example, so it is easy to direct clients to the website over the phone. So I hope to create a permalink structure without any numbers if that is feasible.
Forum: Themes and Templates
In reply to: Broken CSS navigation calls for dynamic body IDI found out what the problem was and the solution. Turns out another fellow was using a very similar method for creating body tag IDs.
Problem one was syntax. I was missing brackets in the 4th line after wp_title.
Problem two, for some reason, wordpress was inserting white space in my source before the body tag id. This calls for using something called trim to clean up the code.
Here is the link to the solution.
https://www.ads-software.com/support/topic/extra-spaces-when-echoing-wp_title-for-body-tag-id?replies=4I will leave the code, with corrections to line four, for anyone else who may use this same method for creating unique body tag IDs.
<?php if (is_front_page()) { ?> <body id="home"> <?php } else { ?> <body id="<?php echo trim(wp_title('', false)); ?>"> <?php } ?>
Forum: Themes and Templates
In reply to: Broken CSS navigation calls for dynamic body IDHey esmi,
I want to thank you for taking the time to respond to my problem. Unfortunately, I think you’ve grossly overestimated my ability. ??
I have read A LOT of the codex in my attempts to get familiar with wordpress. I’ve read the page about function body_class 3 times from start to finish before posting here. I have already tried to use body_class as my solution, but could not get it to work on my own.
If you are still willing to help me, I will explain how you can. Please directly and specifically answer either of the two following questions:
1) Please respond to my original question, which was what I have done wrong with the following code snippet, and how to go about fixing this code:
<?php if (is_front_page()) { ?> <body id="home"> <?php } else { ?> <body id="<?php echo wp_title; ?>"> <?php } ?>
2) If you absolutely think body_class is the best solution, please explain your alternative in detail. How does body_class dynamically create the body tag ID, how do I make it output custom ID tags, and how I can see what value is being output on a given wordpress page?