New answers tagged

-1

I found in this file: wp-content\plugins\woocommerce\includes\class-wc-countries.php: public function get_address_fields( $country = '', $type = 'billing_' ) Set required to false and the email would be optional.


0

If I'm understanding your comment properly, then the solution is quite simple. In the StackOverflow answer you have this line right at the top: add_action( 'woocommerce_before_shop_loop', 'ps_selectbox', 25 ); What that line does is take the function you created (ps_selectbox) and it hooks it into the woocommerce_before_shop_loop action hook. WooCommerce ...


0

Within the wp_get_document_title() function we have: // If it's a search, use a dynamic search results title. } elseif ( is_search() ) { /* translators: %s: search phrase */ $title['title'] = sprintf( __( 'Search Results for “%s”' ), get_search_query() ); so you could hook into the ...


0

From what we have to go on, it sounds as though your locations will become WooCommerce product categories (or tags). You can also create new categories if you're already using WooCommerce's default category.


0

Add this code to your functions.php: function hide_menu_items( $items ) { if ( is_page( 'Enterprise' ) ) { // You can use page ID, slug or title here foreach ($items as $key => $item) if ( $item->title == "Blog" ) unset( $items[$key] ); } return $items; } add_filter( 'wp_get_nav_menu_items', 'hide_menu_items', 20 );


1

Try the tag_cloud_sort hook: add_filter( 'tag_cloud_sort', 'shuffle_tags', 10, 2 ); function shuffle_tags( $tags, $args ) { shuffle( $tags ); return $tags; }


0

In order to rename you have to alter your code like bellow. You code was missing absolute path of the directory. That's why your code was not working. Adding ABSPATH will fix the code. rename( ABSPATH . "wp-content/uploads/Directory/Clients/$Client_Name", ABSPATH . "wp-content/uploads/Directory/Clients/$New_Name" ); Why not you use ...


0

That's probably padding from your theme's page style so it's more of a theme issue than Elementor's issue.


0

Background-color: body.custom-background { background-color: #0f0f0f; /* Color for the two borders */ } #page { background: #0f0f0f; /* Color for the content/body part in the center */ } #site-generator { background: #0f0f0f; /* Color for the footer part in the center */ } You can also take it together into one snippet that changes the ...


0

The code exactly as you put it in your question works fine for me and does exactly what you suggested. To make it work I had to make sure my WP post editor was in code editor mode as HTML or Visual Editor may create extra problems: And this is what my test code in the post editor looked like, when I had a successful test: <!-- wp:html --> <p>...


2

Possibly what you're looking for is 'single sign on' or SSO. There's a plugin called WP Auth Server which provides SSO between Wordpress websites without the need for any extra sign-on service. Maybe it'll do what you want. I don't have first hand experience with this or SSO in Wordpress but have set it up in other contexts. Connect your app to WordPress or ...


1

You should use the PHP modulo operator for that. Since you need two different layouts, you should calculate your classes numbers according to $count % 2 and ($count + 1) % 2: <?php $count = 0; foreach ($howtoplaycontent as $hpc): ?> <div class="row courses_row" style="background-color: #f8f8f8"> <div class="...


0

This may be a terrible way to go about population of a CF7 field... However, the way I have done so in the past is to use an identifier as the default value of the field you want to populate, for example {{cf7_year}}. I would then use a mixture of PHP to query and get the values (if required), and format that result into a string that can in-turn be used in ...


0

$post_args = array( 'post_type' => 'post', 'posts_per_page' => -1, 'meta_key' => 'field_name', 'meta_value' => 'field_value', ); $post_query = new WP_Query( $post_args ); $posts_array= array(); if ( $post_query->have_posts() ) { while ( $post_query->have_posts() ) { $...


2

That's not how filters work. Much like a filter in real life, something goes in, it gets changed, and the result goes out. Filters always take in a parameter and return something. They're an opportunity to change something So if we take this: $review_num_fetch = apply_filters('tourmaster_review_num_fetch', 5); This means the plugin uses 5, but it has given ...


1

You need to register separate routes for each scenario you want to cover (ie, cat & tag, just cat, or just tag), all done in the single add_action call. The regex you have will support the comma separated tags. The next thing to do is change how you set the 'term' parameter as part of the 'tax_query' array parameter. It's expecting an array of strings, ...


0

This worked for me: <?php if($_GET['module_search'] && !empty($_GET['module_search'])) $keywords = $_GET['module_search']; ?> <!-- Set args for search of cpt --> <?php $args = array( 'post_type' => 'lectures', 'order' => 'ASC', '...


1

In version 4.2.1 they add the function esc_html to the option text. Here the link to version 4.2.0 for comparison.


1

It's because you're not actually putting the result of ltrim() and rtrim() back into the variable. Those functions return the trimmed value, they don't modify the passed variable. So you need to do this: $post_url_rel = wp_make_link_relative(get_permalink( $post_id )); $post_url_rel = ltrim($post_url_rel, '/'); $post_url_rel = rtrim($...


0

Using wp-cli eval-file is great. You can even do it on a remote system (using an ‘@‘ ssh alias) with a local script. If you have your code in one-time.php in the wordpress base directory and you have a command line on the system you want to run against you can do: wp eval-file one-time.php If you have the file one-time.php locally and you want to run it ...


0

Add a HTML Widget to your footer and place the content in there. WordPress Admin > Appearance > Widgets. I've just tested with the following JavaScript snippet and this works as expected. <script type="text/javascript"> console.log('Hello World') </script>


1

// You can retrieve your link and get the id (contact ID=4 for example) $link = $_SERVER['HTTP_REFERER']; $page_id = url_to_postid($link); if (page_id == '4'){ $subject = "This subject line is for the Contact page."; } else { $subject = "This subject line is for every other page."; }


0

I solved the issue with help from this answer: https://wordpress.stackexchange.com/a/159570/176615 // add nofollow to Amazon function add_nofollow_content($content) { $content = preg_replace_callback( '/<a[^>]*href=["|\']([^"|\']*)["|\'][^>]*>([^<]*)<\/a>/i', function($m) { if (strpos($m[1], "...


0

Welcome to StackExchange! I made some changes to your code that I pointed out with comments. I'm not sure if this will actually work so you have to try it, and probably your way of echoing the message won't work because after updating there's a redirect so you'll have to work with the admin_notices action and find some way to persist the message after ...


0

No, there's no need to use wp_set_current_user(). I was wondering how to fire wp_head action if single post by certain users (either by user ID or username)? You can use $post->post_author to get the ID of the author of the post, and put the user ID list in an array, then just do in_array() to check if the author ID is in the ID list. For example: ...


0

I can confirm that not all contents will be deleted, yes the attachment (maybe also post) will be deleted, but another post types is no, including post revision and page (invisible on admin but actually still on database) To make sure, you will need to manually iterate and delete them with wp_delete_post() before you use the wp_delete_user()


Top 50 recent answers are included