Tag Info

New answers tagged

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?


0

The reason this doesn't work is because there is a redirection happenning after the save_post action. One way you can acheive want you want is by implementing a quick work around using query vars. Here is a sample class to demonstrate: class My_Awesome_Plugin { public function __construct(){ add_action( 'save_post', array( $this, 'save_post' ) ); ...


0

If you want to catch the input before the login completes, I would think you might just hook the wp_authenticate action and run your script there. "This action is located inside of wp_signon. In contrast to the wp_login action, it is executed before the WordPress authentication process."


2

Using get_page_by_title() along the line of below exemplary code should work: if ( get_page_by_title( $page_title, $output, $post_type ) == NULL ) { $exists = false; } else { $exists = true; } Explanation: $page_title is obviously what you are looking for; $output can be OBJECT, ARRAY_N or ARRAY - Default: OBJECT; $post_type can be specified, ...


0

I'm NOT actually Answering the question, I'm putting here, how I got my solution without being on that course: First of all, I got the initial solution to the enqueue problem from WPSE answer. It's working like a charm. But the problem of conflicting re-occurred when I tried embedding the Media Uploaded to a field with wp_enqueue_media(), it's not working ...


0

I figured out the problem. I was referencing the wrong page ID in my add_settings_section() call.


1

You can use this function in functions.php of your current theme It will show an extra field on login form ###################Code starts here ################### <?php add_action('login_form', 'add_login_field'); function add_login_field() { ?> <p> <label for="user_pass">My Input<br> <input type="text" ...


0

And.... the answer was actually correct, if you are using the correct functions. As Milo pointed out, it's wp_enqueue_script not scripts. add_action('wp_footer', 'print_my_script'); function print_my_script() { if(did_action('my_custom_action')) { wp_enqueue_script('listings'); wp_enqueue_script('isotope'); } } Hopefully this ...


0

You can run a query using get_posts to retrieve posts from a specific author, and exclude certain categories, and then use count to return the amount of posts. get_posts uses the same parameters as WP_Query, so you can have a look at the parameters there <?php $args = array( 'author' => 1 //ID of the author 'posts_per_page' => -1, ...


0

You need something like the following: $metabox_array = array (array('view1', 'Metabox for View 1', 'Render View 1', 'Post', 'normal', 'default', 'view2', 'Metabox for View 2', 'Render View 2', 'Post', 'normal', 'default', 'view_x', 'Metabox for View_x', 'Render View_x', 'Post', 'normal', ...



Top 50 recent answers are included