Tag Info

New answers tagged

0

I think similar question is answered here: Send user activation email when programmatically creating user Please have a look. Let me know if that solves the issue.


3

The last line tells WP to run this function on the pre_get_posts hook. That hook is the ideal place to modify the main query that will be run in order to build the page. In this case, exclude_featured_tag() checks whether WP is loading the home page, and whether it's about to call the main query for the page (as opposed to any other secondary queries being ...


0

I think this issue is handled by WooCommerce in their plugin. It also creates its own tables and this is how they take care of Collation part. (I am referring to file class-wc-install.php of WooCommerce). They have written following code in the create_tables function global $wpdb; $collate = ''; if ( $wpdb->has_cap( 'collation' ) ) { if ( ! ...


0

There are some plugins that do this functionality of adding the Twitter avatar as the default user Avatar for WordPress, Twitter Avatar Reloaded Add Local Avatar


0

You could provide your editors textarea's ID to get the content of the tinyMCE, also you should get the contents of the saved post meta and set it as the text of your editor element to display the value saved before. You could use the following code as a reference, <?php function taggr_meta_function($post){ $my_editor = get_post_meta($post->ID, ...


0

So I found out the problem was in the database. If I deleted the page, then re-created it then it functioned as it should. I couldn't narrow down what exactly was wrong with the data, but something was. That page did have a lot of revisions, not that it should matter?


0

I found the solution. You have to de-regsiter and add the wp-mediaelement script to add the features.


1

First, you need to to find out what your current version of MYSQL... WordPress requires MySQL 5.0 or greater Since its a VPS, I'm assuming its a linux installation. Just type mysql -V on the command line and it will return your MYSQL version. If the version is compatible with wordpress, this message may be a "plugin/theme related" message. Look at your ...


0

Well.... you could use the correct Field in the $_POST, which would be $_POST['post_id'], not $_POST['post-id'] ;) Replace update_post_meta($_POST['post-id'], 'whole_avg',$whole_avg); with update_post_meta($_POST['post_id'], 'whole_avg',$whole_avg); etc. ;) Happy Coding, Kuchenundkakao


1

So, how to have the flexibility to pass variable into any Wordpress' action/filter and while maintain the flexibility to cancel them later? You could assign the function to one of the class's properties: public function __construct() { $foo = 'bar'; $this->init_func = function() use ( $foo ) { echo $foo; }; add_action( ...


0

As the dashboard uses the menu_position 2, just use menu_position 1. so: $args = array( 'label' => __( 'programmes', 'hiblio' ), 'description' => __( 'Programmes for application from partner organisations', 'hiblio' ), 'labels' => $labels, 'supports' => array( 'title', 'editor', ...


1

One way could be to use classes and objects. It's more efficient considering reusability, collective work and more. I don't think it's bad to use global variables if you know what you're doing. So I would recommand you to use OOP (object oriented programming) especially with inheritance and polymorphism.


1

Finally figured it out. Using the plugin mentioned above (linked here for ease) and the basics of the answer to this question I was able to cobble together this code It's a bit hamfisted, I'll admit that (mainly replacing the preg_match with strstr) but it got the job done. I'm open to any improvements you all can think of so please feel free to comment ...


-2

Post thumbnails in WP are stored as meta-data. In /wp-includes/post-thumbnail-template.php, WP retrieves the post thumbnail ID by using the _thumbnail_id value, which can be used as a filter in your WP_Query. When used in this way, WP will check the retrieved posts to see if that meta_key value exists, and if so, it will include those posts in the query, ...


0

it's a little difficult to debug something when no errors are being displayed. i'd first check your php error logs, which normally appear in ....\logs\php_error.log or ....\logs\apache_erroe.log depending on your php.ini settings. chances of getting an immediate answer to your question will be difficult unless you can provide the actual error that's popping ...


0

If I understand correctly, you want your CPTs to show on regular archive pages (cateogires, main query etc) but when searching only your CPTs you get again your CPTs with all regular posts etc.. Here is what I made and for now as I have seen it is working well, but you never know where you can get any error so here, try it and see if it works well for you. ...


0

Mamaduka answer pointed me to the right direction, here is the code for adding classes to the body in the dashboard. /** * Add a class or many to the body in the dashboard */ function add_admin_body_class( $classes ) { return "$classes my_class"; // Or: // return "$classes my_class_1 my_class_2 my_class_3"; } add_filter( 'admin_body_class', ...


0

This is what I came up with and it works exactly as expected. Being a novice, is this a better solution than the solution posted by Aris Blevins? If not, why? I honestly do not know. <?php /***** Display Functions *******/ function rpt_display_content ($content){ global $rpt_options; if(is_single()){ ob_start(); ?> <div ...


0

You appear to be quite close to having this all sorted out. If you wrap your queries in a function, and separate the logic and presentation: <?php function wpse_158425_get_terms(){ global $wpdb, $rpt_options; $wpdb->show_errors(); $rpt_days = $rpt_options['number_days']; $rpt_term_ids = $wpdb->get_col(" SELECT term_id ...


0

I'm assuming your plugin is working, you just don't get the stylesheet stuff to work? In that case, you can use the wp_enqueue_scripts action. http://codex.wordpress.org/Function_Reference/wp_enqueue_style#Using_a_Hook For usage with a stylesheet in the pluginfolder, you can use it like this: function my_plugin_name_scripts() { wp_enqueue_style( ...


1

Well they share a same name... try to declare name as array. <select name="custom_element_grid_class[]" id="custom_element_grid_class">


0

You have the add_action that's supposed to hook your prfx_meta_save function inside the function itself, so it never gets hooked or called. You need to move the add_action outside the function. This will never work: function prfx_meta_save( $post_id ) { add_action( 'save_post', 'prfx_meta_save' ); } Move it outside the function: function ...


0

Simple and easy. Taken from WP if ( ! function_exists( 'is_plugin_active' ) ) require_once( ABSPATH . '/wp-admin/includes/plugin.php' ); and then any instances of if ( is_plugin_active( 'feed-them-social/feed-them.php' ) ) { } get the function check. SO no more errors.


0

Take a closer look at add_settings_field(); your callback is the same as of add_options_page(). You've already set up your input function. Just change site_quotes_output_settings to site_quotes_main_create_input and everything should be fine: add_settings_field( 'sometext', 'Some text!', 'site_quotes_main_create_input', 'site_quotes_plugin', ...


0

Ok i got it. The solution is to use an earlier hook for checking plugins. But then the function get_plugins() is not available so i have to include it for using. The working code: class acf_multisite_sync { function __construct() { add_action('plugins_loaded', array($this, 'acf_sync_init')); } function acf_sync_init() { if ...


1

Here is the correct way to include jQuery in your theme. Open functions.php in your theme folder and add this to it: // Proper way to enqueue scripts and styles function royal_insert_jquery(){ wp_enqueue_script('jquery', false, array(), false, false); } add_filter('wp_enqueue_scripts','royal_insert_jquery',1); This will load the ...


0

If a plugin is written well (or the theme) than you have no reason to worry about duplicate jquery loading. if your theme uses header.php to load jquery then your doing it wrong and should use enqueue scripts to load jQuery... Wordpress uses wp enqueue script to declare scripts once and not multiple times. Example of loading scripts the right way: ...


0

Another example: /** * Register new database table */ add_action( 'init', 'register_litho_quiz_table', 1 ); add_action( 'switch_blog', 'register_litho_quiz_table' ); function register_litho_quiz_table() { global $wpdb; $wpdb->litho_quiz_results = "{$wpdb->prefix}quiz_results"; $wpdb->litho_quiz_questions = ...


2

This is not possible the way you think. It would maybe be possible if you use Reflections or debug_backtrace(), but there's no reliable way to do this. WordPress does not keep a stack or queue where it tracks file names. The only thing I could imagine is just hooking into the action and inside wp_enqueue_scripts(): wp_enqueue_scripts and attach a ...


1

You need to remember screen id of your page and check current screen id before adding new menu item: add_action( 'admin_menu', 'my_plugin_menu' ); function my_plugin_menu() { global $my_swell_plugin_page; $my_swell_plugin_page = add_menu_page( 'My Swell Plugin', 'My Swell Plugin', 'edit_posts', 'blah', 'generate_main_page' ); } function ...


1

Maybe the $current_screen object can help you: global $current_screen; if ( $current_screen->base == 'toplevel_page_blah' ){ add_action('admin_bar_menu', 'add_toolbar_items', 100); } I haven't tested it but it should do the trick.


1

Ok the problem i found in your above code is you have not mentioned the path of your library function em_bookings_events_table() { ........ ....... ....... wp_enqueue_script('name_of_script','place Path_of_your_jquery_file here'); } add_action( 'wp_enqueue_scripts', 'em_bookings_events_table' );


1

The proper way to include jquery in your plugin is /** * Proper way to enqueue scripts and styles */ function theme_name_scripts() { wp_enqueue_script( 'script-name', get_template_directory_uri() . '/js/example.js', array(), '1.0.0', true ); } add_action( 'wp_enqueue_scripts', 'theme_name_scripts' );


0

As ungestaltbar said, the variable "data" should contain an object, not a string. function show_trend() { var data = { action: "render_admin_charts_page" } jQuery.ajax({ type: "POST", url: "../wp-admin/admin-ajax.php", data: data, dataType: 'json', ...


0

You could insert a $wpdb->show_errors(); to output the errors in your query. Also you need to input that sql into dbDelta($sql) did you miss that?


3

The form action needs to point to options.php, which is WordPress' built-in handler for all settings pages: <form method="POST" action="options.php"> This is documented fairly thoroughly on the Settings API page of the Codex.


0

You have to call views(); when rendering the page content. Put <?php $wp_list_table->views(); ?> after page title and before the form. See: \wp-admin\edit.php to see when is called.


-2

For Wordpress metabox file upload in custom post. please refer Below link http://code.tutsplus.com/articles/attaching-files-to-your-posts-using-wordpress-custom-meta-boxes-part-1--wp-22291 or you can use following plugins https://wordpress.org/plugins/simple-fields/ http://www.advancedcustomfields.com/ both plugin best for custom field . you can ...


0

This is not a real answer regarding the question. The only effective but dirty solution seems to be in hooking into : 'option_active_plugins' and kick off all other plugins but yours. That of course leaves the admin interface in a very confusing state to the user but at least you can avoid collisions between modern Javascript applications or Javascript ...


1

Your filter: function add_query_vars_filter( $vars ){ $vars[] = "getvar"; return $vars; } add_filter( 'query_vars', 'add_query_vars_filter' ); Is correct. When WordPress starts assembling the list of query variables, this function will add 'getvar' to the list. But then you immediately check if the variable is set before it reaches that point. The ...


0

You're not using wordpress default ajax mechanism. To do that: jQuery.ajax({ type: "POST", url: "/wp-admin/admin-ajax.php", // Send request to admin-ajax.php data: newcontact, // Can be anything. As per your need action: 'myaction', // Required to send otherwise Wordpress AJAX won't authorize your request. success: function(data) { ...


0

Ok, the problem was, that the token / domain on Multisite was empty and the API returns NULL. Have anyone an idea, how i can inspect the Request / Response with this API Calls over WordPress Updates?



Top 50 recent answers are included