Forum Replies Created

Viewing 13 replies - 1 through 13 (of 13 total)
  • It seems like there are lots of different problems and potential solutions here, but after trying every other suggested solution, none of which worked, I found something that worked. Add:

    flush_rewrite_rules();

    after you call register_post_type.

    https://www.ads-software.com/support/topic/permalinks-404-with-custom-post-type?replies=25#post-1893532

    I have tried about everything and read a bunch of the related code in WordPress. The only thing that worked for me is to add:

    flush_rewrite_rules();

    after my call(s) to register_post_type. But at least that totally works.

    Thread Starter mattifesto

    (@mattifesto)

    Thanks for the response. Since it seemed so obvious, I was almost sure you had a reason and since I never code for PHP4 I didn’t know what it was.

    I’m looking forward to version 4.0.

    OK, I figured out the “Fatal error: Cannot redeclare class” problem.

    My activation hook function was a static method on the main plugin class:

    register_activation_hook(__FILE__, 'MyPluginClass::activate');

    In this function I included another file. In this other file, I used the $this variable mistakenly forgetting it was a static function so there was no $this. If I get the class instance as I should, for instance from a global, the error goes away.

    In any case this is a bizarre and misleading error meaning there is an error in the activation hook.

    Thread Starter mattifesto

    (@mattifesto)

    It also seems like mysql2date is the function a could expose this functionality, but using the $translate parameter has no effect.

    the_permalink() will only work for single posts, not pages with multiple posts or archives. To do that, use the PHP $_SERVER global.

    When I came to this topic, I was looking for how to make my sites return to the current page after a user logged in, instead of the admin page. Here is the solution to that specific question:

    wp_loginout($_SERVER['REQUEST_URI']);

    This will create a log in or log out link (as appropriate) that will return the user to the current page.

    There’s more discussion on the topic in this bug:

    https://core.trac.www.ads-software.com/ticket/9963

    I’m writing a plugin and testing it on WordPress 2.8.4, and it seems that now you must call stripslashes on all values returned from get_option.

    I would think the correct thing would be for WordPress to do this for you as described above, since it update_option the slashes for you in the first place.

    Can someone please definitively say whether stripslashes is supposed to be required or not?

    My guess is that they tried to add it in, but it broke too much stuff and they had to take it out again. But either way, it should be documented in the get_option function reference. We just need to know how it’s supposed to be.

    Yeah, this is annoying. I hope they consider it to be a bug.

    edit: I was thinking this could be solved by just changeing the basic query to sort sticky posts first and then use the same logic used before sticky posts. No need to do programming logic for it.

    I don’t quite know how to fix it, but I know two things that make the error stop.

    First, my error was getting “page not found” on the LAST previous page of links on the main index page. The page would actually show up correctly, but “Page not found” would be in the title. If I had a 404.php it would cause that to be invoked.

    First fix:

    1. Changing permalinks to “Default” will fix it. But nobody’s going to do that. (By the way I totally did all the .htaccess stuff others talk about, it didn’t help for this case.)

    2. Removing this line from my theme and changing number of posts per page from 9 to 6 in settings instead also fixed the problem:

    query_posts($query_string . '&posts_per_page=6');

    For me, that gets the same result.

    I’m guessing, and right now it’s just a guess, that when post_per_page is set and doesn’t match the post per page in the settings, that wordpress potentially gets confused. Part of it says, “Hey, I’ve calculated and at 9 posts per page there is no page 3! Page not found!” And then another part says, “Well there actually is a page 3 because I’m currently using 6 posts per page. So I’ll just return the results.”

    If anyone else experiments and finds similar (or conflicting) results, please post about them.

    Forum: Fixing WordPress
    In reply to: Disabling tooltips

    I’m having this exact same problem. I list my categories to make a pull down menu and then the tooltips pop up as well and it’s highly annoying.

    I was hoping use_desc_for_title=0 would do the trick but it doesn’t seem to.

    Update:

    Since I’m using jQuery to make the menu anyway, I just added this line to my setup code:

    $("#pulldownmenu a").removeAttr("title");

    I was nervous about removing the title from all cases and this just removes them from the specific menu I want and won’t if javascript isn’t enabled. Works perfectly.

    Just a note where I made a mistake. I was trying to do this on the archive page, and you have to remember to include the existing query_string in the query or that information will be lost which means your category view will no longer be a category view.

    It also means functions like is_category() won’t work anymore after you call query_post because I assume they use the query_string.

    So this is the more correct version:

    query_posts($query_string . ‘&meta_key=popularity&orderby=meta_value’);

    Me too, it’s driving me crazy. And it only seems to happen on one of my blogs all hosted through the same account.

    Hmmm… I’m surprised nobody mentioned there’s a very easy way to do this.

    Assuming you have a custom field you’ve named ‘popularity’ all you have to do is place this before your first call to have_posts() in archive.php (for instance if you wanted all category views etc to be sorted by popularity)

    query_posts(‘&meta_key=popularity&orderby=meta_value’);

    It’s as simple as that.

    Caveats: This will exclude posts that don’t have a popularity custom field, but for people that know every post will have some value for a custom field, it’s a much easier and less fragile method of sorting by a custom field.

    (btw, I was unable to get an ampersand to show up in a code block on these comments. It would always show as & no matter what, so I just used blockquote instead.)

Viewing 13 replies - 1 through 13 (of 13 total)