WordPress: My Ajax call always returns 0 in Internet Explorer – what’s going on?

This post is for everyone who have exhausted all Ajax options on stackoverflow and still return a response body of 0.

Go to your functions.php and check your add_action which should look similar to the below:

add_action('wp_ajax_myfunction', 'myfunction');

This is perfectly fine and works … if you’re logged in to WordPress already.

You need to add a second add_action line

add_action('wp_ajax_nopriv_myfunction', 'myfunction');

This will now work for users who were not logged in to WordPress.

If that fixed your ajax issue

You simply forgot to add an action for users without privileges. For any form that was being submitted that’s going to hurt as that data probably wasn’t captured.

Side note:

The above has absolutely nothing to do with Internet Explorer apart from the fact that you most likely aren’t logged in to the CMS on IE.

More refs:

PDFmyURL and complicated SVGs

PDFmyURL is a quick tool to convert dynamic HTML content to PDFs.

Recently we ran into issue on a project where it could not render complicated SVGs (these SVGs were floorpans with multiple layers/plans in each).

The issue:

The page technically finished loading before the content could draw – but because PDFmyURL had a successful page load it created the PDF while the SVGs drew – which produced incomplete looking PDFs.

The fix:

A quick (but workable) fix was to get the file contents of the SVG, remove the unnecessary layers and then base64 the leaner SVG in an <img> tag like so:

<img src='data:image/svg+xml;utf8,<svg ... > ... </svg>'>

Not ideal but it worked, PDFs now generated as expected.

Why do my imported WordPress posts have different IDs

Q: Why do some of my imported WordPress posts from my old site have different IDs on my new site?

A: You added ACF (advanced custom fields) which also use page IDs. On your live site you continued to make posts while working on your development. When you imported your posts the post IDs increment as they were already taken (by ACF components). As a result you will need to look out for old post URLs that now map to attachments or incorrect posts – these will look like 301 redirects and not 404’s.

This should only affect you if your permalink structure finishes with %post_id% instead of %postname% as it’s the ID which has incremented.