Skip to main content
Share Your Experience: Take the 2024 Developer Survey
13 votes

WordPress AJAX File Upload - FrontEnd

Hi You have Use this COde For WordPress front-end AJAX file upload tutorial Code Here is my code: In my template file example.php <form enctype="multipart/form-data"> <input type="text" ...
Adnan Limdiwala's user avatar
11 votes

How to use nonce with front end submission form?

Use the following code inside just before tag on your front end code. wp_nonce_field('name_of_your_action', 'name_of_your_nonce_field'); The above code will generate two hidden inputs inside your ...
Kamal Ahmed's user avatar
10 votes

How to use nonce with front end submission form?

To add a nonce to a form you can use the following function: wp_nonce_field($action, $name, $referer, $echo) $action = (optional) this is a string which represents the action name $name = (optional) ...
Ascendant's user avatar
  • 199
10 votes
Accepted

Why are my frontend theme styles bleeding into the backend?

You're supposed to enqueue on the wp_enqueue_scripts event. Placing the function in functions.php and immediately running it, will make it run on all pages, including the admin area Here's an example ...
Tom J Nowell's user avatar
  • 59.4k
8 votes

How do I fetch the static front page using the REST API?

We could implement our own endpoint: https://example.tld/wpse/v1/frontpage Here's a simple demo (PHP 5.4+): <?php /** * Plugin Name: WPSE - Static Frontpage Rest Endpoint */ namespace WPSE\...
birgire's user avatar
  • 67.4k
6 votes

Way to display media library in frontend

As far I've understood with those I've written a simple system for you. Please put the below codes in your functions.php- add_action( 'wp_enqueue_scripts', 'the_dramatist_enqueue_scripts' ); ...
CodeMascot's user avatar
  • 4,527
6 votes

Is there any filter to disable the total fronted in WordPress

By Killing WP on non-admin Pages The below code will determine whether you are on a front-end page or not, and kill WP if you are. add_action( 'init', 'my_function' ); function my_function(){ ...
Johansson's user avatar
  • 15.3k
5 votes

Disable front end to use as CMS only?

Although this is a rather old question with an already accepted answer, someone might find this useful, specially since none of these solutions worked for me. function redirect_to_backend() { if( ...
dev_masta's user avatar
  • 226
5 votes

is_admin() returns true when using admin-ajax.php from front end script

is_admin() always returns true for every AJAX call. If you want to validate AJAX calls from frontend only, this may be a work-around: if (!isset($GLOBALS['current_screen']) && !...
Minh Tri's user avatar
  • 3,419
5 votes
Accepted

Create and move terms for taxonomies

wp_update_term() doesn't changes taxonomy. It just updated the existing taxonomy. Say the below code- $update = wp_update_term( 1, 'category', array( 'name' => 'Uncategorized Renamed', '...
CodeMascot's user avatar
  • 4,527
5 votes
Accepted

Insert wp_editor on front-end with AJAX?

So, after doing some more digging, I answered my own question by "connecting the dots", so to speak. There's a lot of bits and pieces of info on this topic on StackOverflow and StackExchange, but none ...
Swen's user avatar
  • 1,374
4 votes

How to Layer 7 Load Balance WordPress Backend and Frontend?

The problem #1 & #2: Don't know why you need to add and validate extra cookies, but for me, it's simple and quite straight forward: This is what I have tried on vagrant boxes and with default ...
Minh Tri's user avatar
  • 3,419
4 votes
Accepted

WP Admin Bar frontend issue with dashicon deregister

Well, the dashicons are used in the admin bar, so if you deregister them, your admin bar is broken. The easy way out is only to deregister the icons if there is no admin bar: add_action( '...
cjbj's user avatar
  • 14.6k
4 votes

wp_enqueue_scripts hook is not being called

For anyone getting this problem in an admin page, use the admin_enqueue_scripts hook instead of the wp_enqueue_scripts hook. Documentation here.
ban-geoengineering's user avatar
4 votes
Accepted

Is it secure to use admin-ajax.php in front?

I would like to know if it is secure to use admin-ajax.php for your ajax requests on the front. There is nothing fundamentally insecure about using it for AJAX requests as a protocol. So is it ...
Tom J Nowell's user avatar
  • 59.4k
4 votes
Accepted

Fullscreen Video/GIF Intro

The following code uses HTML5 Video, with the muted & autoplay attributes set. It takes the video, which I uploaded through the media gallery and displays it fullscreen. I'm using a script that ...
RiddleMeThis's user avatar
  • 3,767
4 votes

How To Import CPT With Only Few TEXT ACF Fields From Front End?

I'm not quite sure if there are any plugins that work out of the box the way you describe. You might want to do some research on the many importing plugins published for WordPress to see, if any of ...
Antti Koskinen's user avatar
4 votes
Accepted

Frontend Post - Allow Only Image File Upload

You can check mime type of uploaded image before upload to media. Add mimeTypes in $allowmimeType which you want to allow. then check uploaded files mimetype $fileMimeType. If not found in allowed ...
Chetan Vaghela's user avatar
3 votes

Are there any action like 'init_frontend'

Late to the party, but found the other answers not quite as clear. There is no init-like hook that is front-end only. admin_init only runs in the dashboard. init runs on both the front-end as well ...
random_user_name's user avatar
3 votes

How to get shortcode working from custom meta field

You can do this by using 'the_content' filter. That way, Wordpress will treat the content as it was came from the editor field and execute all the shortcodes: <?php $meta = get_post_meta($post->...
André Gumieri's user avatar
3 votes

ajax call in wordpress front end

There actually is an integrated solution in WordPress core to use Ajax on the front end! WordPress has a little-known but very useful javascript library that can be accessed via the JS object window....
Philipp's user avatar
  • 1,232
3 votes
Accepted

Front End Registration Form Code - Password Field Not Saving

$user_data has incorrect array key for password. It needs to be user_pass instead of user_password. For more reference please check out wp_insert_user()
Piyush Rawat's user avatar
3 votes

Disable or Enable Comments on Front end

Actually it's there within WordPress by Default. If your WordPress editor is not showing it, then from the top left corner, click the Screen Options drop down menu. It'll show some check boxes. Among ...
Futuritous's user avatar
3 votes
Accepted

How to link Wordpress heartbeat to ajax form

Saving data Based on Heartbeat API, you can add custom data to the sent heartbeat on heartbeat-send event in js. This would be used instead of the ajax function you have in your code example. jQuery(...
Antti Koskinen's user avatar
2 votes

WordPress AJAX File Upload - FrontEnd

HTML <form id="article_form" name="article_form" class="wordpress-ajax-form" method="post" action="<?php echo admin_url('admin-ajax.php'); ?>" enctype="multipart/form-data" > &...
Asha's user avatar
  • 140
2 votes

Disable front end to use as CMS only?

IMO, a plugin would require less work and is more appropriate for the specific case. <?php /* Plugin Name: Disalbe Frontend Description: Disable the frontend interface of the website, leave only ...
nikksan's user avatar
  • 121
2 votes
Accepted

Datepicker not supporting timepicker

Wordpress supports only datepicker. If you want to add timepicker in datepicker you have to use jquery-ui-timepicker-addon as extension in your theme or plug-in. Add css and js as below add_action('...
user19922801's user avatar
2 votes

Assign category to front end post

I checked and it works with this: $new_post = array( 'post_content' => $_POST['post-content'], 'post_title' => wp_strip_all_tags( $_POST['post-title'] ), 'post_type' => ...
10Y01's user avatar
  • 59
2 votes

Frontend Password change

I think you are referring to two different things.. 1) Verifying the request. You should be using WP Nonces to verify the request and protect it against XSS. That should be a practice for all your ...
Motaz M. El Shazly's user avatar
2 votes

limit file type and file size using media_handle_upload

Use PHP // Check that the nonce is valid, and the user can edit this post. if (isset( $_POST['my_image_upload_nonce'] ) && wp_verify_nonce( $_POST['my_image_upload_nonce'], '...
P-S's user avatar
  • 556

Only top scored, non community-wiki answers of a minimum length are eligible