Hot answers tagged

11

So I'm answering my own question, for those that face or will face the same problem. I have added two buttons. One opens wordpress' build-in window to select a post and inserts the link. The other opens wordpress' build-in media window to select an image. That is what somehow what you get at the end. You will need two PHP functions and one JS one in a ...


8

I had the exact same problem and found the solution to this. The problem is that the anchor plugin for TinyMCE is not being included as part of the default Wordpress install. So while Wordpress says to include: $buttons[] = 'anchor'; …that's not going to work because the TinyMCE plugin for anchors isn't there. If you go to TinyMCE's website, you can ...


7

You can add button via add_meta_box function. function add_your_meta_box(){ add_meta_box('your-metabox-id', 'Title', 'function_of_metabox', 'custom_post_type', 'side', 'high');} add_action('add_meta_boxes', 'add_your_meta_box'); function function_of_metabox() {?> <input type="submit" class="button button-primary button-large" value="Add New" ...


6

It looks like you're trying to use classes from the WordPress admin styles on the front end. However, those styles are not loaded. You have two options, one of which I wouldn't recommend. Way #1: Do this What I would recommend is that you simply copy and paste the buttons styles you want into your child theme or custom CSS plugin (example, one of many). ...


6

Like this: function custom_js_to_head() { ?> <script> jQuery(function(){ jQuery("body.post-type-YOUR-CUSTOM-POST-TYPE .wrap h1").append('<a href="index.php?param=your-action" class="page-title-action">Import from ...</a>'); }); </script> <?php } add_action('admin_head', 'custom_js_to_head'); ...


6

With WordPress 3.5+ Media Uploader, there's another way. All strings are localized at the bottom of the page with: <script type='text/javascript'> /* <![CDATA[ */ var _wpMediaViewsL10n = { "url":"URL", "addMedia":"Add Media", "search":"Search", "select":"Select", "cancel":"Cancel", "selected":"%d selected", "dragInfo":"...


5

The code below should be something similar to what you're looking for Inside the loop template you use for listing blogs (like index.php) you need something like this <a href="<?php the_permalink(); ?>/#respond"> <!-- The blog permalink with the anchor ID after --> <i class="fa fa-comments-o"></i> Leave a Comment </a>...


4

You can use the WooCommerce hook woocommerce_after_add_to_cart_button. This hook will add content after the "Add To Cart" button. If the customer clicks on this button, the product should get added to the cart, and the customer should be send to the checkout page. Add the below code in your child theme functions.php /* Create Buy Now Button ...


3

Here is something i have used before as a solution for changing the post category (or any term/taxonomy) just make sure you set the right $post_type,$append,$taxonomy,$terms <?php /* Plugin Name: Simple Ajax set cat Plugin URI: http://en.bainternet.info Description: dead simple lightweight plugin to add a post row action link to set a post category by ...


3

There is an action before the Trash link: post_submitbox_start. You can use it to add content to that box. The Trash has a float:left, so it will move to the side. Example: add_action( 'post_submitbox_start', function() { print '<button>Hey!</button>'; }); Result:


3

Your div wrapper is within your while loop, and split by your if clause. This cannot work properly, since your loop will generate up to 14 divs with the id ajax. Put the opening div tag after if ( $the_query->have_posts() ) { and the closing after wp_reset_postdata(); and you should be fine. Edit Are you sure, that you didn't miss any opening/closing ...


3

Use media_buttons action for it. Check below code. add_action('media_buttons', 'add_my_media_button'); function add_my_media_button(){ echo '<a href="'.get_site_url().'/wp-admin/customize.php" class="button button-default">Customize</a>'; } Hope this will helps you. Thanks!


2

it you're not seeing the buttons, try to call QTags._buttonsInit(); right after you call the quicktags( settings ); function. quicktags(settings); QTags._buttonsInit(); Following also works for me qt_editor = new QTags( { 'id': 'my_editor', 'buttons': 'strong,em,link' } ); QTags._buttonsInit(); Also, it seems that adding a button via QTags.addButton() ...


2

This is the intended behaviour on an iPhone or other mobile device (it's called 'responsive design'). Because you have a much narrower screen on a mobile it's very likely that if you have more than four or five top-level pages, the navigation menu starts to wrap on to two lines and become messy & difficult to use. There's no simple disable option, ...


2

Your method is complex... Here is simplest function to add BUTTON in TinyMCE: (insert this code in funcitons.php): add_action('admin_init', function() { if (current_user_can('edit_posts') && get_user_option('rich_editing') == 'true') { add_filter('mce_buttons_2', 'register_buttonfirst'); add_filter('mce_external_plugins', '...


2

It's simple, use the function is_user_logged_in: <?php if ( is_user_logged_in() ) { ?> <a hef="link-for-logged-users"></a> <?php } else { ?> <a hef="link-for-users-not-logged-in"></a> <?php } ?> See here http://codex.wordpress.org/Function_Reference/is_user_logged_in


2

This didn't work for me. I had to do the following: $args = array( 'posts_per_page' => -1, 'post_status' => 'trash' ); $trash = get_posts($args); foreach($trash as $post) { wp_delete_post($post->ID, true); }


2

You can style a link as a button with the button css class: <a href="#" class="button">I am a button</a> You can modify a button with the primary styling by adding button-primary: <a href="#" class="button button-primary">I am the primary button</a>


2

In the code you posted there are some errors, that maybe are only typos, in general the name of your inputs do not match with the name of the related setting. When you save your settings as array, name must be always in the form array_name['option_name'] but for radios you don't follow this rule (but you do for others field). Using your code I've only ...


2

WARNING: using the hook "attribute_escape" is kinda bad. This function is called for ALL text including post titles and content. Using this filter as stated in the accepted answer breaks html entity encoding. For instance the title Features & Pricing appears as Features & Pricing in the title field. After saving it then shows Features &amp; ...


2

Instead of redirecting to a new page, you can use the one you're already on with basic logic similar to this: if ( !empty( $_POST['ticket_action'] && ( $_POST['ticket_action'] == 'noshow' ) ) { $ticket_post_id = $_POST['ticket_post_id']; ... you probably want to check if the user is logged in or check for a valid nonce here ... // do ...


2

1) Is your function working? First do a console.log( "it's working" ); inside your function and check it on your browser's console. If it's not showing when you click, you must refactor your function. 2) Have you defined ajaxurl? Unlike on the admin side, the ajaxurl javascript global does not get automatically defined for you, unless you have ...


2

The CSS comes from wp-includes/css/buttons.css. Do not change this this file; it will be overridden during the next update. Create a separate plugin instead, or add some custom code to your theme’s functions.php, and hook into login_head: add_action( 'login_head', function() { ?> <style> .button { background: red !important; } </style&...


2

No no no! Never POST or link directly to a custom PHP file - WordPress won't be loaded, and to load it manually yourself means making huge assumptions about the file hierarchy. Use the ajax API, which exists specifically for this reason: $.ajax({ url: "<?php echo esc_js( admin_url( 'admin-ajax.php' ) ) ?>", type: "POST", data: { ...


2

Use the_content hook and hook only when you are on a single page: add_filter( 'the_content', 'my_button_function' ); function my_button_function( $content ) { // See if it's a single post or a loop if ( is_single() && in_the_loop() && is_main_query() ) { return $content . "<button onclick=\"buttonAction()\" p style=\"...


2

Finally, I make it, the way without losing the access to WordPress environment: add_action( 'edit_form_after_title', 'custom_button' ); function custom_button() { $button = sprintf('<a href="%1$s" class="button button-primary button-large">%2$s</a>', esc_url( add_query_arg( 'link' , true, get_the_permalink() ) ), 'Custom Button' ); ...


2

The <a> tag is the wrong tag for a submit button. <input type="submit"> and <button> are designed for this purpose. An <a> tag won't even submit the form data. You need to change your HTML to accommodate this fact.


2

For this three possibilities: If you really want to do it on order place you would have to use the hook: woocommerce_new_order However I would recommend you use the hook: woocommerce_order_status_completed This would make sure that the order is finished when you send then information. To catch the information before billing you could always use: ...


2

Try changing the z-index in the css of the button. button#btn-show { z-index: 10; }


2

Ok, so it’s pretty easy error - just a typo ;) You use this line to localize your script: wp_localize_script( 'ajax-script', 'my_foobar_client', array( 'ajax_url' => admin_url( 'admin-ajax.php' ), 'we_value' => 1234 ) ); So you use ajax_url field to store url to admin-ajax.php But you use this line in your js file: my_foobar_client.ajaxurl, and ...


Only top voted, non community-wiki answers of a minimum length are eligible