How do I assign this filter to a variable? (Appending php & markup to the_content)

Congratulations on (nearly) solving your problem already 🙂 There are 2 comments below the post that attempt to say how to do it the right way They are proposing to do it this way: function weedub_affiliate_filter($content) { $string_to_add = ”; if (is_single()) { $string_to_add = $string_to_add . ‘the string you wanted to add’; } $content … Read more

wp_editor in add_meta_boxes does not show gallery

Make sure tinymce option has a valid value. Remove it or set it to true if you don’t pass any parameters to tinymce $editor_config = array( ‘teeny’=>true, ‘textarea_rows’=>10, ‘editor_class’=>’csec_text’, ‘textarea_name’=>’csec_body’, ‘wpautop’=>false, ‘tinymce’=>$tinymce_options //THIS OPTION SHOULD BE VALID ); Edit: Made a small research. Add wpview in plugins argument of tinymce options. $tinymce_options = array( ‘plugins’ … Read more

Adding Custom Metaboxes to Custom Pages

The add_meta_boxes hooks load in edit-form-advanced.php. Your custom plugin page “test” does not use that file. You need to hook into the “plugin admin page hooks” instead. Secondly, the third parameter of add_meta_box is just the CPT slug, not the page slug you have. Here is what you need to change: add_action(“load-my-cpt_page_my-cpt-slug”, “my_add_metaboxes”); function my_add_metaboxes() … Read more

prevent post submission

See the Codex, on save_post. In answer to Question 1, it is fired whenever WordPress auto_saves a revision (i.e. hence when a post is edited). In particular, when creating a new post, wp-admin/post-new.php is loaded. WordPress then creates an auto draft even if you haven’t saved a draft or published to post. This is intended … Read more

How to save the checked boxes?

You can use PHP in your functions.php file to insert inline JavaScript (including jQuery) using WordPress hooks. In your example, you could use the admin_print_scripts-post.php action hook to print your inline jQuery like so: function wpse_admin_print_scripts_edit() { echo “<script>var limit = 2;’ . ‘jQuery(‘input.single-checkbox’).on(‘change’, function(evt) {‘ . ‘if(jQuery(‘input.single-checkbox:checked’).length > limit) {‘ . ‘this.checked = false;’ … Read more

How to Change the Title of a Meta Box on a Specified Custom Post Type? [duplicate]

Yes – you need a slightly modified version of this answer. add_action( ‘add_meta_boxes_post’, ‘wpse39446_add_meta_boxes’ ); function wpse39446_add_meta_boxes( $post ) { if( ‘mycpt’ == get_post_type($post) ){ remove_meta_box( ‘authordiv’, ‘mycpt’, ‘core’ ); add_meta_box( ‘authordiv’, __(‘Team Member’,’wpse39446_domain’), ‘post_author_meta_box’, ‘mycpt’, ‘advanced’, ‘high’ ); } } Note: If you are doing this for a non-core metabox, you’ll need to ensure … Read more

Displaying Saved Meta Box Data in Drop Down with selected()

<?php selected() ?> compares the value of the stored data and which option should appear first, my error was that I wasn’t storing the variable to compare it to correctly. $selected = isset( $values[‘location’] ) ? esc_attr( $values[‘location’][0] ) : ”; should be changed to: $selected = isset( $custom[‘location’] ) ? esc_attr( $custom[‘location’][0] ) : … Read more

Color picker for posts and pages

I have found the solution on Denis Žoljom’s post 1) – I have added the metabox like this add_action( ‘add_meta_boxes’, ‘mytheme_add_meta_box’ ); if ( ! function_exists( ‘mytheme_add_meta_box’ ) ) { function mytheme_add_meta_box(){ add_meta_box( ‘header-page-metabox-options’, esc_html__(‘Header Color’, ‘mytheme’ ), ‘mytheme_header_meta_box’, ‘page’, ‘side’, ‘low’); } } 2) – enqueue the color picker style and script add_action( ‘admin_enqueue_scripts’, … Read more

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