Tag Info

New answers tagged

0

Like they said it's hard coded into WP core, and it's best practice to not mess with the core. However the title is located in <span class="screen-reader-text">Post Title</span> just use CSS to hide it. .screen-reader-text{ display: none; }


0

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" ...


2

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'); ...


1

The earliest safe hook to get post information is the template_redirect hook. All the hooks in question runs before Wordpress has setup postdata, so any post info are still unavailable at that point. The globals like $wp_query and $post will still contain no data, that is why your efforts returns nothing. EDIT Extra info as per comment by @TheDeadMedic ...


1

Just small nuggets of information that may help in simple setups (most notably the ones with no use plugins using ob_start): 1) You don't need the to put dns-prefetch calls as the first elements. What you need is to put them as soon as possible before any other element calling external resources. 2) Is actually possible to use negative numbers as priority ...


0

Because you need to give your function a parameter: function auto_follow_admin( $user_id ) { // Now you can use $user_id, which is passed to the function from the hook caller }


1

You want the has_action() function. add_action( 'category_promo_header', function () { echo 'hi there'; } ); if (has_action('category_promo_header')) { echo '<div>'; do_action('category_promo_header'); echo '</div>'; } Comment that add_action and you should see that nothing is printed at all.


2

Add another preg_replace. Something like: $text = preg_replace('/<a href=\"(.*?)\">(.*?)<\/a>/', "", $text);


0

You can use "save_post" action-hook Add the code below into functions.php and enchance with your comment_meta code. function update_comments_meta( $post_id ) { // Do whatever add/update_comment_meta code you need } add_action( 'save_post', 'update_comments_meta' ); UPDATE. As an example i've attach code below. It performs on post save/update ...


2

With the lastest version of WordPress (4.3) you can now natively remove the customizer's theme switch setting without resorting to CSS hacks. /** * Remove customizer options. * * @since 1.0.0 * @param object $wp_customize */ function ja_remove_customizer_options( $wp_customize ) { //$wp_customize->remove_section( 'static_front_page' ); ...


0

How is $_GET['post'] set ? And why are you checking it? It could be that you're adding the save_post call too late. Try: function foo() { die('Saving post'); } function foo2() { if( isset($_GET['post']) ) foo(); } add_action( 'save_post', 'foo2' );


0

Follow the following steps to achieve your result, Use get_terms to fetch all of your parent taxonomies and render a drop-down with the title and setting a data attribute with the term ID. Please set the args "parent" to 0 and taxonomy to your taxonomy slug. Write a jQuery script to fire an AJAX on the above created drop-down. The AJAX should send the ...


0

@David explained why your code doesn't work and sketched out a solution (use save_post instead). However, you can "chain" hooks together so that you should still be able to use the transition filters to control execution: function create_recurring_posts( $ID, $post ) { add_action( 'save_post', function() { // debug, since I don't have a ...


2

Plugins are loaded before the theme which means that your apply_filters won't have any actual callbacks registered to it. Instead, you need to call your apply_filters sometime after the theme has been loaded. Something like this: /* Your plugin's file: */ add_action( 'init', 'my_lovely_funky_filters' ); function my_lovely_funky_filters() { /* Fire our ...


0

This is the correct method - except the function is apply_filters, not apply_filter. Hence your error.


1

Have you seen this ? http://stackoverflow.com/a/28429009/3967385 Actually you can't fire JavaScript with php simply like that.


0

Your action is triggered in wp_transition_post_status() which gets called by wp_insert_post() before the action save_post is triggered. save_post is the typical action to handle custom fields. ACF also works on this. Basically you have to wait until ACF is done with its stuff, means you'll have to hook to save_post with a priority > 10 or better use ...


0

Firstly, remove the margin-left CSS property from your html and then try if it works. May be your html is being hidden behind any other html. Or better try this first - Remove the current code from your function and just write any non html thing. Then put a die() or exit() and see if it's being rendered properly. Then you can do further debugging.


0

It's actually pretty simple to change the title in content-product.php, but you won't be able to do it with a hook. Near the top of the file, you should see this line: Override this template by copying it to yourtheme/woocommerce/content-product.php All you have to do is copy the file to the above directory, replacing "yourtheme" with your theme's actual ...


-1

in WordPress, you cannot just "overwrite" a hook (that's works only for pluggable functions) but, you can add new fonction to the same hook and remove an action. try something like this : add_action("init", function () { // removing the woocommerce hook remove_action('woocommerce_shop_loop_item_title', 'change_product_title'); }); // add a new ...


1

No, you cannot do that, unfortunately, because get_header( $name ) doesn't have a filter for the $name (it only passes the name with the action call). However, if you are willing to modify the header.php file for each site with something like this right at the beginning of the file: <?php if ( apply_filters( 'load_custom_header', false ) ) { ...


0

Thanks WisdmLabs. I traced it finally after the discussion. The changes in product page are appearing now. Below is the mistake I have done.I am posting this as it might help others with similar problems. In my plugin I am calling file B in file A using require_once. I have placed my function timeslot_display() and hook calling line in file B which did not ...


4

WP doesn't "look" at the type of data you have, it just has a default of CHAR. So if you dump your current query you will see respective type cast: CAST(wp_postmeta.meta_value AS CHAR). To make it work you need to specify type argument explicitly 'type' => 'NUMERIC' and CAST will change accordingly: CAST(wp_postmeta.meta_value AS SIGNED). See Custom ...


0

Building on Phil's answer: Made the following change to the switch: case 'extranet_sort_document_case': add_filter('posts_join', 'extranet_clientdocument_case_join'); add_filter('posts_fields', 'extranet_clientdocument_case_fields'); add_filter('posts_orderby', 'extranet_clientdocument_case_order'); break; and wrote the following functions: function ...


1

(I was going to add this as a comment as it's not a full answer, but I can't yet...) I think you will need to use an SQL query as the standard meta_queries / orderby won't work. Have a look at Custom Table Column Sortable by Taxonomy Query and http://wpdreamer.com/2014/04/how-to-make-your-wordpress-admin-columns-sortable/#sorting-posts-option-b for a couple ...


1

There's an array option when creating a custom post type and custom taxonomy for ""rewrite"" and you can set a ""slug"" and it's there that you can change your permalink structure. For more read here. Also the other option that I get from post 1 and post 2 one helped me blink some idea. 1 Rewrite rule: You need to add a new rewrite rule so Wordpress knows ...


2

juste before testing login and password, you have the action wp_authenticate: https://codex.wordpress.org/Plugin_API/Action_Reference/wp_authenticate juste after test and only if logging is successful, the action wp_login: https://codex.wordpress.org/Plugin_API/Action_Reference/wp_login and after logging, you can also modify the URL with the filter ...


0

You want to use body_class filter. function prefix_add_body_class( $classes ) { global $post; // good to check if( ! is_single() || 'post' !== get_post_type() ) { return $classes; } $btag = get_post_meta( $post->ID, 'tagbody', true ); if ( empty( $btag ) ) { return $classes; } $classes[] = $btag; ...


0

Here is the description of transition_post_status from the codex: This function's access is marked as private. That means it is not intended for use by plugin and theme developers, but only in other core functions. It is listed here for completeness. Use any of these functions instead. Why not use the publish_post action instead? There is a ...



Top 50 recent answers are included