Tag Info

Hot answers tagged

31

the new user email is sent using wp_new_user_notification() function which is pluggable meaning that you can overwrite it: // Redefine user notification function if ( !function_exists('wp_new_user_notification') ) { function wp_new_user_notification( $user_id, $plaintext_pass = '' ) { $user = new WP_User($user_id); $user_login = ...


6

Maybe so? Refined version of my earlier solution. add_filter( 'wp_dropdown_pages', 'add_cpt_to_front_page_dropdown', 10, 1 ); /** * Adds CPTs to the list of available pages for a static front page. * * @param string $select Existing select list. * @return string */ function add_cpt_to_front_page_dropdown( $select ) { if ( FALSE === strpos( ...


6

Ok - so I solved this. Here is what appears to be the problem. Comments are disabled by default for custom-post-types. This happens even if you have them enabled in the overall settings To fix it, all I had to do was the following: In SETTINGS > DISCUSSION uncheck the "Allow people to post comments on new articles" setting. Click "Save Changes" Now go ...


5

You can handle this using the option_default_post_format filter: add_filter( 'option_default_post_format', 'custom_default_post_format' ); // Posts of post_type_1 will be asides by default, but all other post types // will be the default set on the Settings > Writing admin panel function custom_default_post_format( $format ) { global $post_type; ...


4

This is a little late, but I had to figure out the other part of this question on my own and thought I would share. To create a default menu and place it into a theme location, you will need a pre-existing location in the theme, and you will need to ensure any pages you link in your menu are also created already. In your theme's function.php, register any ...


4

The action hook save_post is called on save, but i don't know if you can add metadata at this time. But it should be possible to create/update your meta data after the post was saved with the action hook updated_post_meta. EDIT To pre-select some meta fields (custom fields) on the post creation screen, you have to add these meta values first with an empty ...


4

There is a filter named default_content. It does exactly what the name says. :) Example: add_filter( 'default_content', 't5_preset_editor_content', 10, 2 ); /** * Fills the default content for post type 'post' if it is not empty. * * @param string $content * @param object $post * @return string */ function t5_preset_editor_content( $content, $post ) ...


4

As a security measure, WordPress includes these index.php files to account for hosts that by default enable directory browsing. Including them makes sure that no one can see the list of files in that directory, which could let them know what plugins or versions you are running and thus give them some things to try to hack your site. As long as you don't ...


3

This will do: <?php /* * This filter only works with images, for all kind of media check: media_send_to_editor * The priority is set to 20 and it takes 8 arguments */ add_filter('image_send_to_editor', 'wpse_53577_img_wrapper', 20, 8); // We are only working with the $html argument, but you can play with all of them function ...


3

One simple method is to filter post_thumbnail_html, to add in a default image link: <?php function wpse55748_filter_post_thumbnail_html( $html ) { // If there is no post thumbnail, // Return a default image if ( '' == $html ) { return '<img src="' . get_template_directory_uri() . '/images/default-thumbnail.png" width="150px" ...


3

Why not just create a front-page.php template file, that uses either a normal query/Loop, or (if a custom Theme option is set to display the CPT on the Front Page), outputs a custom query/Loop, based on the CPT? The issue there is that you would have to create a separate Theme option to control the Front Page output, while at the same time instructing users ...


3

Thanks to @toscho for the useful answer, but it felt a bit hackish to me, so I poked around a bit and figured out I could add a filter instead: function wpa18013_add_pages_to_dropdown( $pages, $r ){ if('page_on_front' == $r['name']){ $args = array( 'post_type' => 'stack' ); $stacks = get_posts($args); ...


3

One option would be to modify the global Default Post Format setting, via Dashboard -> Settings -> Writing. Note that this setting is global, so it would set the default for all post types that support Post Formats. If you have no need of post formats for blog Posts, you could simply enable post-format support only for your custom post type, by ...


2

wp_link_pages() and paginate_links() work in different contexts: The first on a single paginated page, the latter on an archive. So is_archive() should be your criterion to decide which text you use, or better: which filter you use in apply_filters().


2

This is the proper method to add custom fields support (you don't get the blank fields when edit posts) function set_default_meta($post_ID){ $current_field_value = get_post_meta($post_ID,'Sort Order',true); $default_meta = '100'; // value if ($current_field_value == '' && !wp_is_post_revision($post_ID)){ ...


2

The code below shows the "post-thumbnail" aka the featured image if the post has one, if not depending on the category, the default thumbnail is shown (with the comments, the code should be self-explanatory): <?php // If the post has a featured image defined use it if( has_post_thumbnail() ) { the_post_thumbnail(); // Default image for Technology ...


2

Unless you have a memcached-type plugin installed, wp_cache_set will only store data for the duration of the current script. Call or add the widget again in the same instance & you'll see it utilise the cache. As for ob_get_flush(), taken from the manual: Flush the output buffer, return it as a string and turn off output buffering In other words, ...


2

Use the second parameter $post and check $post->post_type alongside a switch, it's easier and nicer to work with than several if else if else, etc.. add_filter( 'default_content', 'my_editor_content', 10, 2 ); function my_editor_content( $content, $post ) { switch( $post->post_type ) { case 'sources': $content = 'your ...


2

There is a very easy solution to your problem. Just add a capability to the particular role of this user, through the Wp_Role class. Wordpress has this feature of Submitting for Review active for authors and contributor by default, but, if you want to use pages, you have to give them the edit_pages capability, but not the publish_pages one, so that they can ...


2

This is set during user registration. You can change the value per filter 'user_register'. Sample code, not tested: /* Plugin Name: First name plus last name as default display name. */ add_action( 'user_register', 'wpse_67444_first_last_display_name' ); function wpse_67444_first_last_display_name( $user_id ) { $data = get_userdata( $userid ); // ...


2

I've answered a similar Question. Basically: create a Dropin plugin at the root of wp-content named install.php inside install.php, create a new version of the pluggable function wp_install_defaults() remove all unwanted defaults and customize at will, like: update_option('template', 'your-theme'); update_option('stylesheet', 'your-theme'); ...


1

I'm working on a Php build script using Phing that installs WP along with some defaults (themes/plugins and custom code), it's still a work in progress. https://github.com/wycks/WordPhing/ Inside build.xml you will see some php options like the following which are run during install: //remove Hello Dolly delete_plugins(array('hello.php')); ...


1

default_content runs when a post is loaded into the editor, actually. You can check for categories when the post is saved, but you'd want the save_post hook, probably. You want to check the $_REQUEST global. add_filter( 'default_content', 'my_editor_content' ); function my_editor_content( $content ) { global $_REQUEST; if ...


1

On the Product Edit page for the variable product, click on the "Variations" tab. Once you setup variations for the Colour you can set a "Default selection" at the bottom: http://cld.wthms.co/7LIv This will be the default option selected when a customer visits the page (if it is in stock). Example: http://cld.wthms.co/YQFO


1

You can use has_nav_menu() to check to see if the location has one assigned to it. If it does, use wp_get_nav_menu_items() to duplicate the menu, then assign it to the location you register in your theme. Here's what I have in mind. It's off the top of my head and will need more code and testing, but hopefully it's a good start for you: function ...


1

From your dashboard, visit Settings > Reading and select and for the first option, Front page displays select A static page (select below) and then select that specific page (and then another page you create for your posts to show up on if you would like).


1

just guessing now because lack of info, but it could be in your functions.php and maybe called by the function "wp_enqueue_style()" or try to search your theme folder for default.css and it should give you that file where it being included from. And no it is not a standard inclusion in WP.


1

You should use the save_post action and isolate your operation by checking the post type as this runs on all post types. There is obviously some more logic you will have to build into this to make it work for you. You should probably set a post meta field that checks if you've set the defaults once so your users won't be frustrated if they wish to leave a ...


1

I would hook into the new_page action, and then use update_post_meta() to update the post meta value for _wp_page_template: <?php function wpse31124_set_page_default_template( $page_id ) { update_post_meta( $page_id, '_wp_page_template', 'sidebar-page.php' ) } add_action( 'new_page', 'wpse31124_set_page_default_template' ); ?> You could hook ...


1

Put this code in the top of your api page, it will call in the functions, but you need to tell wordpress NOT to try and draw a page as well define('WP_USE_THEMES', false); // Tell wordpress not to draw out a page require('/path/to/public_html/wp-load.php'); // load wordpress functions



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