Hot answers tagged

3

When looking at either The Codex or Code Reference there's usually a little snippet at the bottom which says: Since: WordPress x.x.x If we take a look at wp_enqueue_script() for example we see toward the bottom above the contributor notes that it has been around: Since: WordPress 2.1.0 Now we can use the WordPress Release Chart to find out when ...


3

Sidebars are stored in global variable $wp_registered_sidebars. You can get the sidebar properties using this variable. global $wp_registered_sidebars; if ( isset( $wp_registered_sidebars['sidebar-2'] ) ) { echo $wp_registered_sidebars['sidebar-2']['name']; } Note that do not use it too early, either on/after widgets_init hook or in a template ...


2

I you want the script be enqueued on page-index.php and page-contact-us.php, then you must check that that page templates are used but you are checking if they are not used. Chagne this: if ( !is_page_template('page-templates/page-index.php') && !is_page_template('page-templates/page-contact-us.php') ) { with: if ( ...


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

Most obvious reason could be the fact wpseo_title filter is firing before you have saved your title. Try moving title_storage() call on a earlier stage like. The wp action should be a good candidate.


2

In general I wouldn't recommend modifying the original uploaded image files, just in case we might need to re-generate intermediate sizes. But let's see if it's possible :-) We can in general let WordPress choose the image editor, that depends on modules like GD or Imagick, through: $editor = wp_get_image_editor( $file ); but this can return an WP_Error ...


2

Here's a workaround: First change the paginate_links() output type to: 'type' => 'array', Then we can collect the previous, current and next parts from the paginate_links() output. Here's a simple example where we target the relevant classes: $next = ''; $current = ''; $prev = ''; foreach( (array) $paginate_links as $link ) { ...


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.


1

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. */ ...


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

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

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

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

depth=n2 should be depth=2. n is just a "placeholder" and should be replaced by the actual integer value of your choice


1

wp_enqueue_script is since Wordpress 2.1.0 https://developer.wordpress.org/reference/functions/wp_enqueue_script/ wp_enqueue_style is since Wordpress 2.6.0 https://developer.wordpress.org/reference/functions/wp_enqueue_style/ Found via a quick google


1

Your shortcode should look something like that function se224467_shotcode_star_rating( $atts ) { $a = shortcode_atts( array( 'grade' => 5, ), $atts ); $full_stars = floor( $a['grade'] ); // full stars $output = str_repeat( '<i class="fa fa-star"></i>', $full_stars ); // if not a whole number append a halt ...



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