chaseman
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: Add HOME Link as Default to the Navigation?Thanks a lot, that’s how I solved this problem now.
But I got a whole new problem, which is, the menus are showing up on top of each other and not next to each other how I would like to have it.
Forum: Fixing WordPress
In reply to: the_category declarationWow that worked great, can it really be that simple?
Thanks a lot man. The thing that was confusing me is that what I was trying worked without any problems with the_title, the post title gets shortened just like I want to, but the same thing does not work with the_category, I’m guessing it has to do with the architecture under the hood which I’m not quite understanding as of now since it all seems a bit messy at first. But I think it is just at first like that and I’ll get into it.
Forum: Fixing WordPress
In reply to: the_category declarationAfter alchmyth’s tip I changed the filter hook name into something more unique and now I’m getting the category string into the function but I have now a whole new problem.
This is the function:
[Code moderated as per the Forum Rules. Please use the pastebin]
The category string WILL be echo’d at text2, but it will NOT be echo’d at substr, it will simply be an empty variable.
Basically I’m not able to do a substr on the get_the_category_list function.Any ideas why I can’t run a substr() function on the category name?
Forum: Fixing WordPress
In reply to: the_category declarationI’ve read that description already, perhaps I’m misunderstanding it, note that English is my 3rd language.
It says that filters take unmodified data and modify it.
I see the category name as unmodified data which is in our example:
“Search Engine Optimization Tips” (way too long) and now I want to modify it BEFORE printing it out to the BROWSER to let’s say 13 characters which is: “Search Engine…”Except you mean something else perhaps? As far as I can see I’ve done everything exactly how the page is describing it, I’ve created a filter function and then I’ve hooked in the filter, so it’s registered in wordpress.
The thing I’m struggling with is how to apply the filter to the function called the_category. Since the description does not say anything about that.
Forum: Fixing WordPress
In reply to: the_category declarationOk I now got it to work with my own variables, I was able to change wit the variable $text = ice; -> cat: ice into cat: i…
BUT, I’m not able pass the get_the_category_list function into my function, it ends up being empty again:
This works:
$text = get_the_category_list( $separator, $parents, $post_id ); $text = ice; apply_filters ('shorten_cat', $text);
And this doesn’t:
$text = get_the_category_list( $separator, $parents, $post_id ); apply_filters ('shorten_cat', $text);
Forum: Fixing WordPress
In reply to: the_category declarationI can’t even induce this into the function:
$text = "ice";
So it must be the apply_filters function that is passing an empty variable.
Forum: Fixing WordPress
In reply to: the_category declarationThe $text variable simply gets induced into the function empty, and I’m not getting any “missing argument errors”.
Forum: Fixing WordPress
In reply to: the_category declarationI just did a bit more testing, the RETURNING itself does work, the problem is that the variable $text is simply empty.
Perhaps I’m inducing the variable wrongly into the function?
Forum: Fixing WordPress
In reply to: the_category declarationThis is the code in the PHP file that I put into the widgets folder:
function shorten_cat ($text) { $chars_limit = 5; $chars_text = strlen ($text); $text = substr ($text, 0, $chars_limit); if ($chars_limit < $chars_text) { $text = $text . "..."; } return $text; } add_filter ('shorten_cat', 'shorten_cat');
And this is the_category function that I edited:
function the_category( $separator = '', $parents='', $post_id = false ) { $text = get_the_category_list( $separator, $parents, $post_id ); echo apply_filters ('shorten_cat', '', $text); }
With this, I get echo’d out an empty space, basically the shortened string does not get returned. I’m not quite sure where exactly the problem lies.
If the string ($text) wouldn’t have been inserted correctly into the function, than I probably would have gotten an error that the function expects a string and nothing else, but that error does not occur.
So I’m assuming that the function is not able to return the new shortened string back.
Any ideas how I could accomplish this?
Forum: Fixing WordPress
In reply to: the_category declarationThanks for the many links, I’ve read into all of them the past hour.
GRAQ, thanks for the tip with the filters I’ve read into that as well, so far I’ve quite understood how it works, there’s only one missing puzzle piece, and that is how do I now apply the filter on the specific function I want it to apply to?
I realize I’d use add_filter, but where do I tell the add_filter function to apply that filter on for example “the_category”, so a too long category like “search engine optimization tips” becomes “search engine …”, since a too long category would break The Loop.
Forum: Everything else WordPress
In reply to: How to Learn All the WordPress Functions?That was what I was looking for, thanks, I didn’t realize you could find it in the post-template file.
Forum: Everything else WordPress
In reply to: How to Learn All the WordPress Functions?That makes sense, thanks for letting me know. Do you know in which file I can find the function declaration, so I can have a look at it myself?
If I would have been able to do that in the first place I probably would have figured it out on my own.
Forum: Everything else WordPress
In reply to: How to Learn All the WordPress Functions?Thanks for the answer, when you say “core code” which files exactly do you mean?
I’ve looked in the files containing the word “function” in the file name which are located in the wp_includes folder, but I couldn’t find the functions I was looking for.
FOR EXAMPLE:
Right now I wrote a function which will take a string and shorten it as soon as it passes a max amount of characters. I used the function on the_title(), which didn’t work, but it DID work on get_the_title(), at this point I don’t know why it works on one but not on the other, and it would help if I could have a look at the functions themselves to figure out the answers to my questions.I tried to use the same self made function on the category inside The Loop, I applied it to the function call the_category(), which again didn’t work, the string would simply remain the same length. If I apply it on get_the_category() I will get the error that is an array.
Perhaps I could get cleared most of the confusing issues if I simply can have a look at the functions themselves. So in that sense your suggestion makes sense. Though, I’d appreciate a tip where exactly to look at, as I said I can’t find the right functions in the files I was looking into.
Thanks.
Forum: Installing WordPress
In reply to: WordPress 3.1 Installtion on Locahlost -> Blank Page ProblemI turned on error reporting by adding:
[code]
define('WP_DEBUG', true);
[/code]into wp-config.php, and it turns out I simply had entered a wrong user name for the database connection, silly me.
Now it’s working.
Forum: Installing WordPress
In reply to: WordPress 3.1 Installtion on Locahlost -> Blank Page Problemno i have created a special folder for my server files inside htdocs and named it “server”.