Using ajax on categories and wordpress loops

Yes this is possible with WordPress but I would not use index.php but a custom front-page.php template then create a page called home and set it as the front page in options-general. For your category menu: <?php $categories = get_categories(); ?> <ul id=”category-menu”> <?php foreach ( $categories as $cat ) { ?> <li id=”cat-<?php echo … Read more

WordPress Ajax always returns a 404 error

This was very frustrating to figure out. I spent hours on this issue and discovered your problem is in this input: <input type=”text” name=”name” id=”name” size=”30″ value=””/> Try changing the input field name to anything but “name”, for example: <input type=”text” name=”user_name” id=”name” size=”30″ value=””/>

ajax live search for post title

Here is a working solution (tested as is) The HTML (could be part of page content) <input type=”text” name=”keyword” id=”keyword” onkeyup=”fetch()”></input> <div id=”datafetch”>Search results will appear here</div> The JavaScript ( goes to your theme’s functions.php ) // add the ajax fetch js add_action( ‘wp_footer’, ‘ajax_fetch’ ); function ajax_fetch() { ?> <script type=”text/javascript”> function fetch(){ jQuery.ajax({ … Read more

Filtering custom posts with Ajax

As pointed by @mmm, I just needed to change the ‘append()’ for ‘html()’. And the use of ‘-‘ instead of ‘_’ in the ‘action’ part. I asked him to post it as an answer so I could close the question, but I guess he didn’t see. So, my final AJAX code is: $(“#opt_filter”).change(function () { … Read more

AJAX handler throws 400 (Bad request) – why?

in your html add `<input name=”action” type=”hidden” value=”test_function”/>` here “value” is your “action_name”. Your ajax call is incorect. Data should be url: “your php action script” data: $(html data).serialize(), About ajax first try to create ajax on your computer without wordpress. When you understand how ajax work try on WordPress.

wp_get_attachment_image returns different image size

Handle built in sizes right I wrote a class that handles all the different stuff for built in image sizes. To redefine the built in sizes, use an extended class (the upper file in the linked source) To unset a class and skip it’s useage completely, just set w & h to 0. http://static.steffenvogel.de/wp-content/uploads/2011/07/octocat_construction.gif Click … Read more