WordPress.org

Ready to get started?Download WordPress

Forums

Breaking Search with index page hack (8 posts)

  1. strom
    Member
    Posted 10 years ago #

    Hi. The ability to search breaks when I turned on hack_file and created a my_hacks.php file with the following code to display a specific category when index.php is displayed:
    <pre>
    if (!isset($cat))
    $cat = 1;
    </pre>
    Actually, search doesn't break completely, only the category specified in the hack is searched. I'm assuming there's code somewhere that specifies which categories to search. Can someone tell me if I can fix this and still keep the hack? Thanks!!

  2. Dougal Campbell
    Member
    Posted 10 years ago #

    After the code above in your my-hacks file, try adding this:
    <pre>
    // Unset $cat if searching:
    if (isset($s))
    $cat = '';
    </pre>

  3. chuckg
    Member
    Posted 10 years ago #

    http://wiki.wordpress.org/index.php/show-one-category-on-front-page
    Explains exactly what I think youre looking for.

  4. strom
    Member
    Posted 10 years ago #

    OK, now I find out that with the above lines are inserted in "my_hacks.php", when archives are selected only the posts present in category 1 are displayed. I tried adding a few permutations such as:
    <pre>
    if (isset($archives)) $cat = '';
    if (isset($a)) $cat = '';
    </pre>
    but with no luck. I've searched through all the files looking for any other string that calls "archives" but can't find anything obvious. Help!

  5. redneck
    Member
    Posted 10 years ago #

    Damn, you're right (I have this enabled on my site too).
    What's going on?

  6. redneck
    Member
    Posted 10 years ago #

    Is if (isset($a)) $cat = ''; the right syntax? Is $a really the variable that matters here?
    I might be able to hack something out, but I'm not sure of the relevant variables.

  7. strom
    Member
    Posted 10 years ago #

    I'm hoping someone can tell us. I don't know enough about WP or php; I was just trying to copy the syntax used for the search variable.

  8. strom
    Member
    Posted 10 years ago #

    I found it! (by trial and error and finding the variable listings for archives in the template_functions.php file.
    is restored to the index page hack by adding:
    <pre>
    if (isset($m)) $cat = '';
    </pre>
    Therefore the entire code for the my_hacks.php file is:
    <pre>
    if (!isset($cat) && !isset($p)) $cat = 1;
    if (isset($s)) $cat = '';
    if (isset($m)) $cat = '';
    </pre>
    Now if I could just figure out my emailing problem....(http://wordpress.org/support/3/3042), I'm good to go.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.