Answer by janh for How to submit form data in the same page in WordPress...
Your jQuery event is bound to elements with the class submit, but your submit button in the form doesn't have that class.Either add that class to the submit button, or just target the form itself....
View ArticleAnswer by janh for Strange gibberish JavaScript in Editor – site hacked?
No, that's not what editors do, and yes, you should be worried.Revert to a clean backup, keep your core and plugins up to date.Change your WordPress and FTP/SFTP passwords. Make sure that there's not...
View ArticleAnswer by janh for WordPress broken after changing URL
Your config in WP is generally correct, but you have "forwarding" enabled at Namecheap, where they just redirect to your IP. Set it up as a real DNS A entry pointing to the IP.Then set up your IIS to...
View ArticleAnswer by janh for Can't write pdf file to upload directory using FPDF
$name apparently contains a URL. That won't work. Set it to a local path, as you did with $filename: $upload_dir = wp_upload_dir(); $filename = $upload_dir["basedir"] . '/deals/deal' . $page->id ....
View ArticleAnswer by janh for Video embeds work in backend, but are not parsed in frontend
I've just looked at the source of the WP_Embed class, and it appears they are not actually registering a shortcode, but hooking into the the_content filter.Change your code to$content_desktop =...
View ArticleAnswer by janh for How to Update multiple rows using $wpdb->update
It is a a bit of a stab in the dark, but I'm fairly confident that the problem is your foreach loop. It's broken (it will not execute anything because only an empty statement (;) is affected, and you...
View ArticleAnswer by janh for Why is my WP Query not returning first result's post meta?
$show_date = get_field('show_date'); $show_venue = get_field('show_venue'); // print '<pre>'; // print_r($show_date); // print '</pre>'; $query->the_post();You are setting the active...
View ArticleAnswer by janh for Why does my user not get added to the database on custom...
$_SERVER["PHP_SELF"] will NOT get you the current URL in WordPress, but will return /index.php (as that's the PHP script that is being executed). WordPress then doesn't know what to do with the data...
View ArticleAnswer by janh for Will WordPress Auto Update work on a site with Basic...
Yes, it will work. For Updates, WP reaches out to the update servers, there is no incoming request that is necessary. Your WP doesn't even have to be publicly reachable at all, you can have it behind a...
View ArticleAnswer by janh for Add indexing to meta_value in wp_postmeta
Don't limit the field, instead, limit the index, e.g.ALTER TABLE wp_postmeta ADD key(meta_value(100))This limits the index to the first hundred bytes of meta_value.You'll probably want an index on...
View ArticleAnswer by janh for curl POST work with user meta but not the custom user meta
You'll get the value as the first parameter, or you could get it out of $request, which is a WP_REST_Request object. Since you're using POST, the parameters out of $request->get_body_params() which...
View ArticleAnswer by janh for How to Handle Going Backwards in Navigation When Referrer...
You could use cookies. Set a cookie for each "level" (Messages, Series, Message) with the URL the user has last been on (including pagination). If no value is set for, say, Messages, because the user...
View ArticleAnswer by janh for How to hide specific categories from contributors
You'll have to change see_special_cats to something fitting. As you want to exclude contributors, but allow all others, you could use publish_posts (See the codex for all capabilities of...
View ArticleAnswer by janh for WP_Query: apply an SQL function to meta fileld value
You can use the filter posts_orderby. For a simple example:add_filter('posts_orderby', 'apply_sql_on_order', 10, 2 );function apply_sql_on_order($orderby, $query) {...
View ArticleAnswer by janh for does wordpress serve static files?
Usually: no.When WordPress is running on apache with mod_rewrite enabled, it'll use # BEGIN WordPress<IfModule mod_rewrite.c>RewriteEngine OnRewriteBase /RewriteRule ^index\.php$ - [L]RewriteCond...
View ArticleAnswer by janh for How to Access custom database content with AJAX onClick...
I'd use the default WP AJAX API so WP can handle all the authentication for you. You'd add a function and an action to trigger it:function wpse_314311_get_quote() { // get quote from db // print json...
View ArticleAnswer by janh for Download external images if post is publish
Scheduled posts don't trigger publish_post, only updating the post itself will do that.Add an action for future_to_publish, see the reference on post status transitions. I don't believe that you'll...
View ArticleAnswer by janh for How do i add a unique body class to the wordpress...
If I'm not mistaken, you could just use body.wp-admin.index-php to target the dashboard.If you want to add something else, you can use the admin_body_class filter to manipulate the classes added to the...
View ArticleAnswer by janh for Most efficient way to get custom database records from 20...
I suppose the easiest way would be to have the action or other parameters in the button itself, i.e.<div class="mybutton" data-action="get_quote" data-type="literary">Get a literary...
View ArticleAnswer by janh for How to fix automatic redirects?
Those aren't really redirects, the "Hash" part of a URL (the # and anything after that) are purely client side and will not trigger another request to your server.The reason for it is AddThis. Here's...
View Article