A message from our CEO about the future of Stack Overflow and Stack Exchange. Read now.

New answers tagged

0

There's no reason for it to be there, and it won't do anything. Only the author would know why it's there, but it's likely a mistake.


0

@Antti Koskinen Sorry I missexplained, this is not coming from Elementor, it is just that I do not know where to put the code :) I have modified the file class-wp-widget-search.php but it did not have any effect. I just added this to the file : 'selected' => 2, Here is complete file code : /** * Sets up a new Search widget instance. * * @since 2.8....


0

You're not too far off in your thinking. Ideally though, you will want to use add_filter to change the value that My_User::login_page_url() returns. Taking your above example, say we have a class called My_User, and the method login_page_url (ie My_User::login_page_url() as given in the example link) looking like this: Class My_User { /** * ...


1

Option 1: force featured image on all posts Use the save_post hook, which runs twice per "save" action if you have revisions enabled. You can verify it's the final run by checking that there is $_POST data (it's empty the first time around). add_action('save_post', 'wpse_force_featured_image', 20, 2); function wpse_force_featured_image($post_id, $post) { ...


0

The fix I did was to put in a filter to deal with the 0 = 1 issue: In my case, I was trying to only affect the product post type, so I didn't want to filter and affect all SQL statements. add_filter( 'posts_where', 'acff_sqlfix', 10, 1 ); function acff_sqlfix( $sql ) { if ((get_query_var( 'post_type' ) == 'product') && (strpos($sql, ' 0 = ...


2

Bitwise operators expect conditionals on either side of them to evaluate to either TRUE or FALSE. If FALSE it checks the next conditional until it finds a TRUE or all conditionals have been checked. Also, the is_page() function doesn't allow parameters to be passed in on a bitwise basis. So simply change your code to the below and you're good! <?php if ( ...


2

Yes, you can use it like: if ( is_product_category('cheese', 'fruit', 'meat') )


0

To set the default value for the category dropdown, you need to pass it as a parameter for the function. Like so, $dropdown_args = array( 'selected' => 2, ); wp_dropdown_categories( $dropdown_args );


0

Wordpress stores three levels of stock information on the wp_postmeta. Each product has manage stock enabled Stock Quantity Stock Status Since the products on the above questions were imported, few of them didn't had manage stock enabled so updating the stock quantity to 0 didn't work well. Solution: I forcefully updated the manage stock to be yes and ...


0

In your first enqueue type get_stylesheet_directory_uri() instead of get_template_directory_uri For stylesheet its functions.php requires get_stylesheet_directory_uri()


0

Based on user35752 answer, you can even use an object method with params as callback. $args = [ [new Foo(), 'bar'], [$param1, $param2, ...] ]; $callback = function () use ($args){ call_user_func_array($args[0], $args[1]); }; add_menu_page( $page, $menu, $capability, $slug, $callback , $icon, $position)


0

I believe plugins are loaded before the theme (see here "plugins_loaded" vs "setup_theme") so the error is occurring because Helper has not loaded yet. One thing you can try is to create a child theme and add the class override there (via functions.php). You can also provide your override after the theme has loaded by hooking into "after_theme_setup" or "...


1

I already had this need, I found this code somewhere in the web. up to you to customize it with your needs. I tested it on the Twenty Nineteen theme: Put this in functions.php : class themeslug_walker_nav_menu extends Walker_Nav_Menu { // add classes to ul sub-menus function start_lvl(&$output, $depth) { // depth dependent classes $indent = (...


0

Document title renders in _wp_render_title_tag. If you want to modify it, you need to remove the WP function and create your own with similar logic. Something similar to this: remove_action('wp_head', '_wp_render_title_tag', 1); And then: add_filter('wp_head', function () { if (!current_theme_supports('title-tag')) { return; } if (...


0

You can add a filter in the title like: add_filter('the_title', function ($title) { if (is_single()) { $categories = get_the_category(get_the_ID()); // Assuming the post has many categories will take the first $category = reset($categories); return $category->name .' - '.$title; } return $title; });


0

Well i think you just do everything inside of TopAuthor and add_action( 'admin_menu', 'TopAuthor' );


0

Add code in your theme function.php file function comment_validation_init() { if(is_single() && comments_open() ) { ?> jQuery(document).ready(function($) { $('#commentform').validate({ rules: { author: { required: true, minlength: 2 }, email: { required: true, email: true }, comment: { required: ...


1

In your child theme (which I am assuming you are using) functions.php file: function wpse_356175_assets() { wp_dequeue_style( 'media-queries' ); } add_action( 'wp_enqueue_scripts', 'wpse_356175_assets' ); Utilise wp_dequeue_style and or wp_deregister_style depending on how the stylesheet was registered/enqueued. If necessary adjust the priority of ...


1

It feels slightly fragile, but you can probably just do: wp_scripts()->add_data( 'gpvb-admin-scripts', 'group', 1 ); in a low-priority admin_enqueue_scripts hook, since that's what wp_register_script does with the $is_footer flag. However this risks a future version of WordPress changing how this is saved internally (although it's been stable for 5+ ...


0

<script src="<?php echo plugins_url();?>/client/jquery.js"></script> <button id="excel" onClick ="$('#dataTable').tableExport({type:'excel',escape:'false'});"> XLS</button> <button id="print">Print me</button> <table class="dash-table" width="100%" cellspacing="0" cellpadding="10px" border="0" id="dataTable"> ...


0

Try this function pen_post_sidebar_twitter() { printf( '<input type="text" name="twitter_handler" value="%s" placeholder="Twitter handler" /> <p class="description">Enter twitter handler without the @ sign.</p>', esc_attr( get_option( 'twitter_handler' ) ) ); } Thanks


0

Use a meta query. Since ACF stores dates as Ymd you can just treat the value as a number: $date_query = array( 'key' => 'start_date', // ACF date field name 'type' => 'NUMERIC', 'value' => '20200101', 'compare' => '<=', // All posts with start date before/on January 1st 2020 ); $args['meta_query'] = array( $date_query ); Any ...


0

HTML <input type="file" id="id_termine_attachment" multiple="multiple" name="id_termine_attachment[]" value="" size="25" /> PHP function upload_file($_FILES) { if (!empty($_FILES['id_termine_attachment'])) { $supported_types = array( 'application/pdf', 'application/vnd.openxmlformats-officedocument....


0

To everyone experiencing the same issue, I have seem to solved it by doing the following: Get a clean copy of WordPress Replace the WP-Content folder Copy your original/existing themes, plugins and upload folder back into that new wp-content That's it... I know, it makes no sense but it somehow did the job.


0

I've finally got it working now, as follows: First I found the original wp_dependencies_unique_hosts() function from the WordPress code (it's in a file called general-template.php), and I made a copy of it, but giving it a new name: wp_dependencies_unique_urls(). I observed that this function is using wp_parse_url() to grab just the host part of each URL ...


0

If you want to include the same type of Schema information about every post, you can do this by creating a child theme. (Instead of editing your theme directly, you create a style.css file that references the parent, and copy just the files you need to modify into that child theme. This way, when you update your parent theme, your customizations aren't lost....


0

You can use "get_avatar" function to display avatar in menu with user name. Please try code given below: add_filter( 'wp_nav_menu_objects', 'my_dynamic_menu_items', 10 ); function my_dynamic_menu_items( $menu_items ) { foreach ( $menu_items as $menu_item ) { if ( strpos($menu_item->title, '#profile_name#') !== false) { $menu_item-&...


0

All the javascript files are embedded in the footer if you remove the footer maybe your site goes down. There are two ways: Create a child theme and create footer.php and call wp_footer(); hook there. Or If you just want to remove the footer text you can do this in CSS just find the class or id and make it display: none;


1

The problem is not that the function you're using adds http:, the problem is it adds no URL schema at all! As a result, WP needs to add a URL schema to turn the host into a URL, and so it uses http://. It has no way of knowing what the original was, or if the host supports HTTPS, so http:// is the safe bet. If however you passed the array with URL schema ...


0

try out this plugin hop it's work for you https://wordpress.org/plugins/woo-bulk-price-update/


0

There's no direct way of getting the post author's email from a post. You can get the email by using the author ID, which is present in standard WP_Post object. $post_author_id = intval( $post->post_author ); $post_author_email = get_the_author_meta('email', $post_author_id); Or if you just have the post ID $post_author_id = intval( get_post_field( '...


1

I think something like the following should work. Uncomment the var_dump to double check you're getting the saved theme mod value you're expecting. If not, check the naming of your customizer setting and that it saved properly. function mytheme_styles() { $theme_dir_uri = get_template_directory_uri(); // enqueue common styles and scripts // ...


1

You can use below code to display theme detail sentence. I have use wp_footer action,You can change hook as per your requirement. function logbook_info() { $theme_logbook = wp_get_theme(); $theme_name = esc_html( $theme_logbook->get( 'Name' ) ); $theme_uri = esc_html( $theme_logbook->get( 'ThemeURI' ) ); $theme_author = esc_html( $...


0

function logbook_info() { $theme_logbook = wp_get_theme(); echo 'The'.esc_html( $theme_logbook->get( 'TextDomain' ) ). 'Developed by '. esc_html( $theme_logbook->get( 'AuthorURI' ) ); } add_action( 'logbookinfo', 'logbook_info' ); Try this.


0

The best solution is to use the filter hook associated with that particular output // Remove the author says from the comment. add_filter( 'comment_author_says_text', '__return_false' );


0

I know that this answer is not completely for this question but there are so many people who come to know how to remove ul and li tag in WordPress and add another tag in WordPress. Like before applying my code WordPress gives these types of output in menu <ul class="*****"><li>abc</li></ul> But someone wants to change ul into div ...


1

Use this code to require the file from your theme's functions.php file: require get_template_directory() . 'includes/dashboard.php'; For the sake of completeness (and sanity) my dashboard.php file lives here: my-theme/includes/dashboard.php I took a closer look at the original issue, and I think what's happening is that the require statement is silently ...


1

esc_attr() is writing for escaping a string that is to be used as an html attribute. When escaping the values of attributes that accept URIs (like href and src), it is important to pass the value through esc_url(). Note: that when using esc_url(), you don’t need to also use esc_attr().


0

You can't do if(the_title()) cuz the_title() this code'll echo a value... Use get_the_title() for a return of the value. Remove this code too: $newtitle = h1 -> outercontent; Do this for check if title is empty: if(empty(get_the_title())){ // Is empty } else { // is not empty } Or you can do only this: if(!empty(get_the_title())){ // I'm ...


Top 50 recent answers are included