Hot answers tagged

3

Loosely what you have should work already. However few things are off. Calling these function without time format will produce values like 1:36 pm (depending on your site's settings), which are not exactly comparable. Post modified time can be less than published in some cases, like scheduled posts. So I would write it along the lines of: if ( ...


3

Add <?php get_footer(); ?> into index.php or the template you are using Then create footer.php and add in something like this: <?php /* Always have wp_footer() just before the closing </body> * tag of your theme, or you will break many plugins, which * generally use this hook to reference JavaScript files. */ ...


2

The priority is related to other actions for the same hook. For example, if another plugin would implement add_action for wp_enqueue_scripts with a lower priority, they would have their scripts loaded in front of yours. You should check what scripts are inserted above yours and see if there is a css conflict.


2

The functions.php is convention for a file that will be automatically loaded by WordPress. From there it is a normal PHP mechanics. You can further include any other PHP files in it. In some themes it is the only thing that a "root" functions.php does.


2

Just few simple ideas: A) Here's one suggestion using the get_search_form filter with a static variable to handle the instance counting: add_filter( 'get_search_form', function( $form ) { static $instance = 0; $instance++; // Setup your form here with the $instance variable as needed: $form = '<form>...</form>'; return ...


2

You need to use two underscores __('String to be translated', 'textdomain') Also, it looks like you're not using the textdomain in the right way


2

get_option is a per sub-site function. In other words it gives you only the value of the option in the sub-site. If you want to have a netwrok wide option you should use get_site_option and update_site_option. You can also query an option from a specific sub-site by using get_blog_option and passing as parameter to it the main sub-site id, but in my ...


2

If you are looking to use HTTPS, I reccomend following this wordpress guide: https://make.wordpress.org/support/user-manual/web-publishing/https-for-wordpress/#implementing-https-for-wordpress You can get a free SSL Certificate from: https://letsencrypt.org/ If you find difficulty setting it up, you can often pay your host a small fee to help set this up. ...


1

It's outputting the word Array which is self explanatory. Instead of direct echoing it, you will need to turn the array into a string. Try implode, something like: Tags: <?php $my_theme = wp_get_theme(); echo implode(', ', $my_theme->get( 'Tags' ) ); ?>


1

You can use the $post object like this, for example: <div class="<?php echo $post -> post_title ?>"> However, you will probably be better-off using the slug instead of the title, as the slug has no spaces in it: <div class="<?php echo $post -> post_name ?>">


1

It's not classified as plugins. It's also not a WordPress glossary and often called: Tabs which are built on Settings API and some tricks with $_GET request. There're many Q&As, references you can learn from. This topic seems to be the most relevant one for you. Yes, you can do it with template_include filter. These Q&As may be helpful too.


1

Why are you making work hard for yourself? wp_create_user already checks if the email/login exists, which is also why your code is "failing" - $user_id will already be a WP_Error, so your elseif ( is_wp_error( $newerrors ) ) never fires. All you need is: $user_id = wp_create_user( $sanitized_user_login, $user_pass, $user_email, $capa ); if ( is_wp_error( ...


1

Thanks to @Max Yudin this is an answer to my problem: function user_content_replace($content) { $sentences_per_paragraph = 3; // settings $pattern = '~(?<=[.?!…])\s+~'; // some punctuation and trailing space(s) $sentences_array = preg_split($pattern, $content, -1, PREG_SPLIT_NO_EMPTY); // get sentences into array $sentences_count = ...


1

First of all, remember that html is for adding meaning and css appearance. If you want to change the text size for sematic reasons, like "this text is a subsection title" or "this sentence is very important", I would advice you not to use <span style="font-size: xx">. It's a better practice for those cases to use <strong>, <em> or a proper ...


1

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 &#8220;%s&#8221;' ), get_search_query() ); so you could hook into the ...


1

You cannot query users by taxonomy. You will need to rethink your system. What would I do? Keep the taxonomies but use these only to output choosable values - wp_dropdown_categories() Save the selected value AS user meta, NOT AS taxonomies - update_user_meta() Now you can query users by that value - WP_User_Query() Example: This code would go to the ...


1

If you want to concatenate function result into a string you should be returning it, not echoing it. Echo just sends it to output. Also you are making a typical mistake of confusing two flavor of WP template tags. Convention is the following: the_* template tags echo result immediately; get_the_* template tags return result. Internally former is usually ...


1

Figured it out after thinking it through.. if (stripos(strtolower($template_filename), 'home') !== false) { $results[] = $template_name; }


1

Best way to check the option before setting the permalink is as follows: if ( get_option( 'page_for_posts' ) ) { echo '<a href="'.esc_url(get_permalink( get_option( 'page_for_posts' ) )).'">'.esc_html__( 'Blog', 'textdomain' ).'</a>'; } else { echo '<a href="'.esc_url( home_url( '/' ) ).'">'.esc_html__( 'Blog', 'textdomain' ...


1

I know this is an old question but get_current_site_name() has been deprecated; use this get_current_site()->site_name or get_current_site()->domain for the domain without the text "Sites" at the end.



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