External api call using wordpress

Your curl request should work from the command line. Put you will want to use make it in a PHP file: $ch = curl_init(); $url = “https://api.com/”; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, 1); http_build_query(array(‘postvar1’ => ‘value1’))); // Receive server response … curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $api_output = curl_exec($ch); curl_close($ch); Which php file you put the curl … Read more

How to use register_setting()

The function register one option or a settings group. So yes, you register the group of a section and use all fields inside this group because the group store all settings fields as array in one item. register_setting( ‘_example_plugin_settings’, ‘_example_object_settings’, array( ‘type’ => ‘object’, ‘default’ => array( ‘some_str’ => ‘A’, ‘some_int’ => 3, ), ) … Read more

Admin Menu for New Post

It looks like you’re trying to add a custom post type called Tutorial. WordPress handles creating the menu all on its own – all you need to do is register the post type. You can start with something like: <?php // Use the `init` hook. add_action( ‘init’, ‘wpse_412823_register_tutorials’ ); function wpse_412823_register_tutorials() { // Set up … Read more

Why my admin-ajax url returns 0 even after adding echo and die() at the end of function?

Avoid using ajax URLs like this when working with ajax calls. Using wp_localize_script is a good way to accomplish this. Let’s assume your js code is in the script.js file. You need to localize that file. function my_theme_enqueue_scripts() { wp_enqueue_script( ‘custom-jquery’, ‘https://code.jquery.com/jquery-3.5.1.min.js’, array(), ‘1.0’, true ); wp_enqueue_script( ‘ajax-script’, plugin_dir_url( __FILE__ ) . ‘js/script.js’, array( ‘jquery’ … Read more

ajax problems on loading page [closed]

I finally find out the problem. The problem is when I load wordpress page a builtin ajax call is started. and this part of my code: jQuery(document).ajaxStart(function() { jQuery( “#step-general” ).hide(); jQuery( “.pelak-loader” ).show(); }).ajaxSuccess(function() { jQuery( “.pelak-loader” ).hide(); }); is used on loading page. I use if conditional in ajaxStart to limit its border!

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)