wordpress-hook

Can I dynamically output a list of 3 recent posts into default text in Wordpress editor?

纵饮孤独 提交于 2020-02-07 01:59:52
问题 I was hoping someone could help me learn how to achieve this. My idea is to generate a list of 3 recent posts from a category (top posts) as a default text in the wordpress editor. I looked at several solutions to achieve something similar and kind of mixed them into the code below, but it doesn't seem to work. add_filter('default_content', 'tp4567_default_list'); function tp4567_default_list( $content ) { $content = new WP_Query( 'cat=2&posts_per_page=3' ); return $content; } Is there any

Remove Woocommerce sidebar from any theme

荒凉一梦 提交于 2020-01-15 15:30:07
问题 I'm using WordPress 4.9.4 running Twenty Seventeen Child Theme theme with Woocommerce Version 3.3.4. I am trying to remove the sidebar… I have tried using this: remove_action('woocommerce_sidebar','woocommerce_get_sidebar',10); But haven't found the right one yet. How do I remove all sidebars? 回答1: The best and simple way that works with all themes is to use the get_sidebar Wordpress action hook this way: add_action( 'get_sidebar', 'remove_woocommerce_sidebar', 1, 1 ); function remove

Wordpress on Ubuntu install plugins without FTP access

一笑奈何 提交于 2020-01-01 04:06:07
问题 I run my own web server for development and, on it, I installed a WordPress instance. When I try to add plugins to this instance from the admin interface, WordPress asks for FTP access. I don't use FTP and have no plans to do so in the future. I know I can change some configuration in WordPress so that I am able to upload without FTP. What exactly should I configure to accomplish this? 回答1: One of three things: Either change permissions so your web server can read the wp-content directory,

Change WP admin post status filter for custom post type

萝らか妹 提交于 2019-12-22 08:20:02
问题 How do you change/rename the text of post statuses in the top of the WP custom post type page All | Published | Scheduled | Draft 回答1: Using the filter views_edit-{$post_type} . Modify the array to set the desired post types: foreach( array( 'post', 'portfolio' ) as $hook ) add_filter( "views_edit-$hook", 'modified_views_so_15799171' ); function modified_views_so_15799171( $views ) { $views['all'] = str_replace( 'All ', 'Tutti ', $views['all'] ); if( isset( $views['publish'] ) ) $views[

Wordpress # to create product link

China☆狼群 提交于 2019-12-11 05:44:06
问题 I'm working on redoing a clients website using wordpress. Their previous developer who wrote the website from scratch, made a products sku/product id with a hash/pound sign '#' in front of the sku/product id number in the text editting of the product in the admin section would create a link to the existing product. I was wondering what language and what the code might look like so I could successfully do essentially the same thing. I've already created in WooCommerce a uniform shortlink to

What is the wordpress hook when I publish a new post, (not when I update a published one)?

别等时光非礼了梦想. 提交于 2019-12-07 06:52:05
问题 I want to send an email any time a new post is FIRST published (not when it is edited) I tried: add_action('publish_post', 'postPublished'); But postPublished is ALSO called when I update an already published post . I just want to get it called ONLY at first time a post is published . Regards 回答1: I think the hook you're looking for is draft_to_publish If you are wanting to only send an email on a new post I would consider targeting when the post is published. You could even look at the

What is the wordpress hook when I publish a new post, (not when I update a published one)?

左心房为你撑大大i 提交于 2019-12-05 11:33:48
I want to send an email any time a new post is FIRST published (not when it is edited) I tried: add_action('publish_post', 'postPublished'); But postPublished is ALSO called when I update an already published post . I just want to get it called ONLY at first time a post is published . Regards DᴀʀᴛʜVᴀᴅᴇʀ I think the hook you're looking for is draft_to_publish If you are wanting to only send an email on a new post I would consider targeting when the post is published. You could even look at the transition_post_status hook and just conditionalize if the post has been edited, something like this

Wordpress on Ubuntu install plugins without FTP access

 ̄綄美尐妖づ 提交于 2019-12-03 11:14:54
I run my own web server for development and, on it, I installed a WordPress instance. When I try to add plugins to this instance from the admin interface, WordPress asks for FTP access. I don't use FTP and have no plans to do so in the future. I know I can change some configuration in WordPress so that I am able to upload without FTP. What exactly should I configure to accomplish this? One of three things: Either change permissions so your web server can read the wp-content directory, which should be fine for a development server. Run PHP as FastCGI which can run as a different user than your