FAQ Database Discussion Community

Why wp_mail() function returns 'false'?

I have a contact form that gets from ajax parameters and uses them to send emails. The function is located in functions.php of my child theme for twentyfifteen: // Contact form Ajax add_action('wp_ajax_nopriv_submit_contact_form', 'submit_contact_form'); function submit_contact_form(){ if(isset($_POST['email'])) { $email = $_POST['email']; $email_to = "[email protected]"; $email_subject = "You have a new...

Best Wordpress Plugin to integrate external API´s

I´m looking for a Wordpress Plugin in order to retrieve data from external api´s and display this data in posts / on wordpress pages. I googled a lot, but haven´t found yet a plugin to do this. Can anyone recommend such a plugin? Any hints are appreciated.

Change upload_dir folder at a certain cpt but cant change back

im try something with the upload_dir filter I check the current CPT with this function function get_current_post_type() { global $post, $typenow, $current_screen; //we have a post so we can just get the post type from that if ( $post && $post->post_type ) { return $post->post_type; } //check the global $typenow...

How to avoid the product's limit for taxonomy in WooCommerce?

Recently I'm faced with an interesting effect which seems to go with default settings. When you just display products in mixed order it's ok, but when you're trying to create custom category for them - there are I'm getting the limit for loop: only 12 products are displayed in tab...

How to add user roles dropdown in registration and login woocommerce wordpress

I have a job site but i want to set drop down with roles i have 2 roles candidate and employer so i want to set a drop down select they roles i am using woocommerce registration and login i want to integrate dropdown with that roles for registration and...

How to change image path in WordPress to subdomain in PHP

I have one big site in WordPress that has many images. I want to speed up site using subdomain to browser load images from subdomain. I want to point subdomain root to wp-content/uploads/ and instead to load from: www.example.com/wp-content/uploads/2015/03/example.jpg I want to load from: www.media.example.com/2015/03/example.jpg Where in PHP I can...

Correct Way to Use AJAX to Update Wordpress Database

I am using the jQuery's sortable function inside of a Wordpress plugin to allow a user to set the display order of a number of list items. When a user re-orders the items, jquery .ajax() should send a request to a processing script to update the table. This is the...

Warning: trim() expects parameter 1 to be string, array given in wp-includes/class-phpmailer.php on line 973

I am trying to send an email from my wordpress website using the function wp_mail and I am getting this error: Warning: trim() expects parameter 1 to be string, array given in /var/www/html/wp-includes/class-phpmailer.php on line 973 0 I don't really understand why I am getting it. This is my current...

Usermeta in wordpress plugin won't save - development

I am trying to create a plugin, in which I have to save a usermeta. The code for adding and saving the usermeta is below. The usermata field is being shown in the userprofile section, but saving it doesn't do anything. Can someone please help me! function add_adslot_text() { ?>...

woocommerce_add_order_item_meta hook sending only one argument; three expected

I am using WC v. 2.3.9. woocommerce_add_order_item_meta gets fired but my callback function only gets one parameter, three expected. I want to add order item meta at the creation of the order. Is this hook really available? Some rumour say that it's deprecated. Edit : after a few research it's...

$wpdb->prepare is not working like mysql_real_escape_string

I'm working on a WordPress plugin and recently I have planned to migrate from SQL to $wpdb. I'm using a method called $wpdb->prepare instead of mysql_real_escape_string but it does not work. Here is what I tried: Code: echo $fetch_row; Output: a:5:{s:9:"task_name";s:10:"Backup Now";s:9:"mechanism";s:10:"singleCall" Code: echo mysql_real_escape_string( $fetch_row ) Output: 'a:5:{s:9:\"task_name\";s:10:\"Backup Now\";s:9:\"mechanism\"...

How to set beforeSend option in wordpress ajax methods

I have just recently learnt how to use Ajax with Wordpress. I'm trying to practice it on my own website and now I'm facing a problem: I cant use "beforesend" option when using $.post! While searching the web, I have found only 2 relevant posts regarding this issue: using beforeSend...

disable update for wordpress plugin named Dropbox Folder Share

I have found the following plugin. Dropbox Folder Share which is licensed under the GNU General Public License. In the plugin I have made some minor changes. mainly added my language. but i have also changed som other things. How can I ensure that the plugin will not be updated....

wp_mail_from: different from address each time

I have a form. Where user gives their name and email address. The I use the custom plugin to send the mail. The requirement is I need to send the mail on behalf of the user who signed. Now in wp_mail how to achieve that? I know about this filter:...

Is there a function that can get me the url of the directory of the file I'm working on? (Wordpress)

I want to include some JS to my theme. I created a folder called "js" in my twentyfifteen-child theme folder. When I want to call the file I write the whole text: <script type='text/javascript' src='http://54.149.xx.xx/wp-content/themes/twentyfifteen-child/js/scroll.js'></script> Is there a function that does that in a more simple way instead of typing...

How to display custom post type in a submenu?

I am adding a submenu named as "Articles" using add_submenu_page() under a custom menu. I want to display the custom post type="page_article" in this "Articles" submenu. Whenever I click on Articles submenu , it should redirect me to "edit.php?post_type="page_article". I have tried with wp_redirect in callback function of add_submenu_page, but...

Why do I get “POST http://54.xx.xx.xx/wp-admin/admin-ajax.php 500 (Internal Server Error)” when using Wordpress+Ajax?

It's the first time for me using ajax on WP. I am working on a simple contact form, and for some reason whenever I click submit I get an error: on console: POST http://54.xxx.xx.xx/wp-admin/admin-ajax.php 500 (Internal Server Error)jquery.js?ver=1.11.1:4 m.ajaxTransport.sendjquery.js?ver=1.11.1:4 m.extend.ajaxmain.js:66 (anonymous function)jquery.js?ver=1.11.1:3 m.event.dispatchjquery.js?ver=1.11.1:3 m.event.add.r.handle on chromes "Networks": Remote Address:54.xx.xx.xx:80 Request...

Slider misbehaving

I've implemented a slider plugin into my theme and unfortunately, some misbevahiour occurs when is activated using the golden info+ button. The highlighted elements, is acting unusual: -the left sidebar text and the lower right arrow, is changing its position going up or disappearing (depending on slider); -the header logotext...

What does internally hosted means

I have built a site in WordPress and the client wants to control things through WordPress but he wants the live version to be static for which someone told me to use StaticPress plugin. He would like to have the WordPress version internally hosted and the live version would be...

How can I add the custom text fields under own plugin of WordPress?

I am creating a plugin I want a functionality of the text fields in admin panel options of the plugin in which I want to set the API key and URL and other things. So how can I add the three text fields in custom plugin?

WordPress template_include filter not working properly

I am working on a plugin. The plugin make custom post type "product". First i use template_redirect action for redirection to single and category pages. Here is my template_redirect code: add_action("template_redirect", 'my_theme_redirect'); function my_theme_redirect() { global $wp; $plugindir = dirname(__FILE__); //A Specific Custom Post Type if ($wp->query_vars["post_type"] == 'product') {...

How to redirect a user with specific “ROLE” to a specific page after login in Wordpress [closed]

I have created a new user role named student_role I want to redirect the user with this role to form page(which I created from wp front end) when he logs in. I tried peter login redirect plugin but failed....

Why do I get the error: “500 Internal Server Error” when passing parameters using Ajax on Wordpress?

I have a dynamic contact form on my Wordspress webpage. This is the HTML structure: <div class="form_content"> <div> Name: <span> <input type="text" id="fullname"> </span></div> <div> E-mail: <span> <input type="text" id="email"> </span></div> <div> Message: <span> <input type="text" id="text"> </span></div> <div id="sendBtn"> Submit </div> </div> I have the functions that grabs the...

How to write following queries in $wpdb

Migrate from mysql to $wpdb so I need to do following queries in $wpdb how to do it? $result = mysql_query( 'SHOW TABLES LIKE "wp_%"' ); $table_descr_query = mysql_query("SHOW CREATE TABLE sites"); I tried like $wpdb->get_results( 'SHOW TABLES LIKE "wp_%"' ); but it doest not works and $wpdb->get_var("SHOW TABLES LIKE...

How to parse wp_get_themes parent data in wordpress

I'm using wp_get_themes and getting data like 'customizr-child' => WP_Theme::__set_state(array( 'theme_root' => 'C:\\xampp\\htdocs\\wordpress/wp-content/themes', 'headers' => array ( 'Name' => 'customizr-Child', 'ThemeURI' => '', 'Description' => 'custom', 'Author' => 'selva', 'AuthorURI' => '', 'Version' => '1.0.2', 'Template' => 'customizr', 'Status' => '', 'Tags' => '', 'TextDomain' => '', 'DomainPath' => '',...

How to work WordPress functions and database [closed]

wordpress experts. I'm searching some help. I know php as well as javaScript and ajax. I have worked a few days with wordpress. But I want to know core functionality of wordpress that means how wordpress functions and database work. I know about codex. But I am not understanding from...

Get Theme and Wordpress version details via API

wordpress gives API for all plugins including change log , version , details, screenshots..etc in http://codex.wordpress.org/WordPress.org_API For example https://api.wordpress.org/plugins/info/1.0/BuddyPress Same way themes and wordpress every version i need to get these details. i have tried with https://api.wordpress.org/themes/info/1.1/ and it shows nothing and i do not know where to modify this...

Add custom CSS to shortcodes

I'm developing a wordpress plugin. This plugin will use shortcodes to display larges chunks of HTML that are styled with Bootstrap 3. However, I cannot depend on whether or not the theme has bootstrap 3 enabled. Is there a way, from my plugin, to ensure that the bootstrap 3 libraries...

Wordpress custom post action hook

I'm working on a plugin for wordpress that I would like to fire every time a custom post of the type 'job' is posted, published, edited, trashed, untrashed, etc. (basically whenever there is an update to that post type). I'm having a bit of trouble finding the correct action hook...

Permission error while developing Wordpress plugin

I'm new to wordpress plugin development & I want to make a plugin. So far I managed to add Menu in Dashboard. Now I want to add a submenu. Menu works when I click on it but submenu doesn't work. It shows this error, You do not have sufficient permissions...

Custom page / message after installation of wordpress plugins

I want to give some tips to the people that install my plugins. So after the installation of the plugin I want them to see an instruccion page, or go directly to the configuration of the plugin. Any hook after the activation of the plugin where I can redirect to...

Is there a difference between Wordpress Multisite (WPMU) and Wordpress, with respects to the hooks and the action reference (API)?

The Wordpress documentation isn't clear about this: http://codex.wordpress.org/Plugin_API/Action_Reference What I specifically need to know is whether add_action("publish_post", "myCallbackFunction") is a hook that will apply across the entire Multisite network, or simply on an individual page (or merely for admins). What I want is that myCallbackFunction is triggered whenever any of...

Wordpress Add my plugin admin menu to my admin new role

I created a new plugin including a admin menu (add_menu_page) I created also a new role "my_plugin_admin_role" Now I would like to add my plugin menu only to my new role. How can'I do this. Sorry for my bad English....

What's a cleaner way to output HTML from a Wordpress plugin?

My Wordpress plugin creates a few shortcodes that return blocks of HTML. When I register the shortcodes, I do so like this: add_shortcode('bb-loans-form', function() { return Shortcodes::loanApplicationForm(); }); And here is the static method from the Shortcodes class: public static function loadApplicationForm() { $form = new \AdamWathan\Form\FormBuilder; $html = $form->open()->action('/apply')->class('bb-loan-form');...

How To Create a Plugin at Backend in Wordpress

I have made a simple contact form plugin and I want it to show on the backend page (wp-admin page).

WordPress plugin settings not saving and getting redirected to /wp-admin/options.php (which generates a 404) on submit

I am creating a WordPress using https://github.com/nadeem-khan/WordPress-Plugin-Template as a starter template. This is my settings class file named 'class-xyz.php': <?php if (!defined('ABSPATH')) exit; class Xyz_Settings { /** * The single instance of Xyz_Settings. * @var object * @access private * @since 1.0.0 */ private static $_instance = null; /** *...

Wordpress submenu_page variable

I'm working on a wordpress plugin for a school project, but currently i'm stuck at one point. I used to have my code on a regular html/php site, not in wordpress. I generated a link with a variable which could be used on the site. How can i do this...

Wordpress change from a plugin (without template edit)

I have made a google search about this but i did not find any answer Is it possible to change the wordpress title without template edit? I want to change <title> Change this from a wp plugin </title> thank you for your help...

Wordpress Pre Fill content in Posts

I have an admin plugin that has a list of articles in it with a button "Add to Posts" along side. On the click of that button, I want to redirect to "/wp-admin/post-new.php" with the form pre filled. I can set the title in the url like wp-admin/post-new.php?post_type=post&post_title=My Titlle. But,...

How Categories Images plugin maps images with term_id?

I'm using Categories Images plugin in wordpress , i want to know that how they are connecting images with term_id i saw database of wordpress there is nothing happens in postmeta table, then how they are mapping term_id to images?

Why do I get “POST http://54.xx.xx.xx/wp-admin/admin-ajax.php 500 (Internal Server Error)” when using Wordpress+Ajax?

It's the first time for me using ajax on WP. I am working on a simple contact form, and for some reason whenever I click submit I get an error: on console: POST http://54.xxx.xx.xx/wp-admin/admin-ajax.php 500 (Internal Server Error)jquery.js?ver=1.11.1:4 m.ajaxTransport.sendjquery.js?ver=1.11.1:4 m.extend.ajaxmain.js:66 (anonymous function)jquery.js?ver=1.11.1:3 m.event.dispatchjquery.js?ver=1.11.1:3 m.event.add.r.handle on chromes "Networks": Remote Address:54.xx.xx.xx:80 Request...

Styling of Custom Plugin in wordpress

I have made a simple contact form plugin manually and I want to style it without inline styling. I also made a css file style.css for its styling but it doesn't worked for me. Thanks in advance for help.

How to change custom admin menu?

I have created an admin menu in wordpress with these functions: function list_menu(){ add_menu_page( 'My Plugin', 'My Plugin', 'administrator', 'mylist', 'list_page', plugins_url('favicon.png'), 24); } add_action('admin_menu', 'list_menu'); function add_menu(){ add_submenu_page( 'mylist', 'Add New', 'Add New', 'administrator', 'add_new_page', 'add_page'); } add_action('admin_menu', 'add_menu'); But it create a menu with duplicate value in the...

Adding Booking Calendar to Wordpress.com Site

As a disclaimer, I am totally new to wordpress, but not web programming. An acquaintance has asked me to add a booking calendar to their wordpress.com site. The calendar would allow a user to select a date for their appointment, fill out a little signup form, and then save that...

Undefined variable in a class when I have defined it

Coding a new version of my own Wordpress plugin, this time using OOP to make it more readable for other collaborators. It is based on Wordpress Plugin Boilerplate and also Cuztom, to facilitate the creation of Custom Post Types. My CPTs are created, they update well. Although I can call...