Tag Info

New answers tagged

-2

To add something just after content, you will need to do something like this. function cfv_post_content( $content ) { global $post; $cfv = get_post_meta( $post->ID, 'wp_c_field', true ); $content = $content . $cfv; return $content; } add_filter( 'the_content', 'cfv_post_content' ); This should add whatever you have saved in wp_c_field ...


0

I got it working in the end by using 'template_redirect' and changing the remove_action number from 8 to 1 :) // Remove 'Genesis Co-Authors Plus' author box and 'filed under' from custom post type add_action('template_redirect', 'lf_custom_cpt_display'); function lf_custom_cpt_display() { if ( is_singular( 'local-bite' ) ): { remove_action( ...


0

This question is pretty old, but here's what I came up with for Wordpress 4.0+ Wordpress oembed wants to store the oembed urls on their own line in the database with no other markup. That's the only way it will work. Try pasting this into the "Text" tab of a page or post: <h2>This Video Won't Work:</p> ...


0

the solution is simple, there is a filter to change the lost password url. Try this : add_filter( 'lostpassword_url', 'wdm_lostpassword_url', 10, 0 ); function wdm_lostpassword_url() { return site_url('/signin?action=lostpassword'); }


2

If you need an alternative way, you can always hook into the login_init and modify the gettext filter: add_filter( 'login_init', function() { add_filter( 'gettext', 'wpse_161709', 99, 3 ); } ); function wpse_161709( $translated_text, $untranslated_text, $domain ) { $old = "Registration complete. Please check your e-mail."; $new = ...


2

The filter in questions filters an array, populated as follows: $result = array( 'user_name' => $user_name, 'user_email' => $user_email, 'errors' => $errors, ); The error message is contained within the WP_Error object stored with the key errors. The WP_Error object (see codex) store no, one or more errors in a ...


0

Here's what I used to disable the parent categories and only allow one category per post. This code changes the quick edit categories, too. I welcome someone to clean it up, I'm not confident in javascript. I got the first part here: https://wordpress.org/support/topic/making-category-selection-radio-buttons /* ONLY ALLOW ONE CATEGORY PER POST */ ...


1

I am not sure why you want to do this, but you can accomplish it with preg_replace(). Try adding this to your theme's functions.php: add_filter( 'admin_post_thumbnail_html', 'remove_featured_image_link' ); function remove_featured_image_link($content) { $content_edit = preg_replace('/<a ...


1

All actions are actually filters internally. So yes, you can do things in a filter hook. However, be mindful of which filters and what you're doing. Some filters are ran everywhere, and doing expensive operations on them may lead to massive slowdowns. Also beware of recursion. If your expensive operation triggers the very filter you've hooked on to..


0

Quick and dirty CSS fix I came up with for Twitter oEmbed (.entry-content is specific to the theme): .entry-content > iframe { margin: 0 auto !important; } Seems to work, YMMV.


0

Just had the same problem and, using your code above, here is how I solved it: function getqtlangcustomfieldvalue($metadata, $object_id, $meta_key, $single) { $fieldtitle="fields_titles"; if($meta_key==$fieldtitle&& isset($meta_key)) { //use $wpdb to get the value global $wpdb; $value = $wpdb->get_var( "SELECT ...


0

That file didnt work for me I had to it in wp-includes/pluggable.php if ( isset( $atts['message'] ) ) { //$message = $atts['message']; $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); $subject = str_replace("[".$blogname."] - ", "", $subject); $subject = str_replace("[".$blogname."]", "", $subject); }


0

The conditional tags must be run after WP object is set up. The wp action hook is the first one through which you can use these conditionals safely. See the warning message in the conditional tags documentation. So, you should hook into wp action (note also that the correct function name is add_action, not add_Action): add_action('wp', ...


1

You can modify your menu by using walker. include('subMenu.php'); $menu = wp_nav_menu( array('menu' => 'YOUR-MENU-NAME','menu_class' => 'megamenu','walker' => new subMenu)); create a file subMenu.php in theme folder add below code. <?php class subMenu extends Walker_Nav_Menu { function end_el(&$output, $item, $depth=0, $args=array()) ...


-2

something like this can be useful: function image_tag($html, $id, $alt, $title) { return preg_replace(array( '/'.str_replace('//','//',get_bloginfo('url')).'/i', '/s+width="d+"/i', '/s+height="d+"/i', '/alt=""/i' ), array( '', '', '', 'alt="' ...


0

I thought that this snippet of code may be helpful for anyone looking to customize the reset password email. //* Password reset activation E-mail -> Body add_filter( 'retrieve_password_message', 'wpse_retrieve_password_message', 10, 2 ); function wpse_retrieve_password_message( $message, $key ){ $user_data = ''; // If no value is posted, return ...


0

Replace the function into your functions.php file - function update_dynamic_select() { update_post_meta($_POST['aid'], $_POST['field'], $_POST['value']); echo $_POST['value']; die(); } Replace options in your HTML part - <?php $val = get_post_meta( 104, '_image_matmenys', true ); $s1 = ($val == "10x10") ? 'selected="selected"' : ''; $s2 = ...


2

Since WP 3.3, there's an action to modify a registered post type after registration. do_action( 'registered_post_type', $post_type, $args ); The $post_type is the post type object and there doesn't happen much after the post type object gets stuffed in the global and before the callbacks attached to this action execute. In fact it's (with WP 4.0) just the ...


0

The basic premise for creating meta boxes from scratch is to first register a metabox, which calls a display callback that you then create and output fields in. And then of course you need to handle sanitizing, saving, and displaying that data yourself. The class you're using isn't really the "WordPress-way" so much as a framework that serves to make ...


0

add_filter("retrieve_password_message", "your_custom_message", 99, 2); function your_custom_message($message, $key) { $message = "your_custom_message"; return $message; } This is an example of usage of 'retrieve_password_message' filter hook. This is to override the email body which someone gets while retrieving the password.


0

You can try out Customer Specific Pricing for WooCommerce. With this plugin, you can add different prices for registered users. Currently the plugin is in its initial phase, but there would be updates soon to support additional features like price based on product category.


2

The third parameter for add_filter is the priority in which the filter is executed, the forth is the number of parameters the function in the second parameter uses. The wpcodex_filter_main_search_post_limits function has an if that checks uses a couple of wordpress function to establish where in your page you are executing the code, in this case it's ...


2

Consider everything that comes with a vanilla WordPress installation a core file. Core files will be overwritten on updates, so it's not safe to edit them. E.g. wp-config.php isn't a core file, because the vanilla installation comes only with the sample version of that file.


1

I think you're looking for the retrieve_password_title filter. For example: add_filter( 'retrieve_password_title', function( $title ) { $title = __( 'WPSE Custom Password Reset' ); return $title; } );


0

Finally, I had to add the required code inside another shorcode I had in place to create the content structure. That way I avoided creating an extra shorcode and was able to put the custom code in the exact position I wanted. Thanks to all those who helped.


2

Redefining a WordPress core function that might be used all over the place by the core, the theme or plugins isn't a very good idea in my opinion. Because it might be used in those occasions expecting the default value to be what default is, which might lead to breaking things. So it is actually not just not a very good idea, it is a terrible one - in my ...


1

You're right. The code you had didn't use any logic to determine whether to add the CSS class or not. Try this: function skips_add_update_status($classes) { //Instantiates the different date objects $created = new DateTime( get_the_date('Y-m-d g:i:s') ); $updated = new DateTime( get_the_modified_date('Y-m-d g:i:s') ); $current = new ...


2

The dashboard_glance_items filter is only useful for modifying the extra elements. The posts/comments data elements have already been displayed. Here are three ideas: Method #1 - Use the dashboard_glance_items filter: You can use the following filter setup, to remove the posts/pages/comments elements from the output of wp_dashboard_right_now(). The ...


3

Unfortunately, there is no 'filter' to remove or edit the previous items in the 'At Glance' box. EDIT I removed the "Wordpress Core Hack" part because I don't want to encourage such a behavior, and I don't want you to edit the code every time Wordpress releases a new version :) And here is a code to append custom post types stats without being clickable : ...



Top 50 recent answers are included