New answers tagged

0

My issue was resolved, not sure if the connection to the database will work, but the error with wpdb connection was fixed. It was quite easy fix once I found out what the file dependence was. This is what you need to do: In the file you are trying to use wpdb you need to add code before you can use the class: <?php require_once('../../../wp-load.php'); ...


0

in_category relies on a global post - it should only be used within the loop. Instead, use the arguments that are passed to your callback to query the categories assigned to the post being edited and check if one of them is video: $cats = get_the_category( $post['ID'] ); if ( in_array( 'video', wp_list_pluck( $cats, 'slug' ) ) { // In "video" category } ...


0

For your particular use case (as far as I understand it now) you just want to use the sticky queries if the access source is different, thus running on a user level not a site level (eg. such as all posts and/or pages option)... Since Multiple Themes is actually fine to run "as is" in admin from the sticky query via cookie (it just doesn't do that by ...


2

I see a couple of problems here. This line if (!is_admin() || 'default' != $domain) return $translated; returns the Howdy right back unchanged if is_admin is false - which it is if you're not in the dashboard. Also, you're running your filter callback on gettext. This means it will be run every time some internationalized content is used, which is ...


0

Okay this is one insanely long answer, but fortunately I was working on testing Theme Test Drive plugin with my theme I figured I may as well make it better compatible with Multiple Themes also by having the admin issue fixed... So here is the code I came up with that handles both. Again, put it in your /wp-content/mu-plugins/ folder (though it probably be ...


0

If you want to apply the add_action and do_action in combination with class object, you have to use a static function to access your class. Try this code with your own wording/variables: class My_Plugin { protected static $_instance = null; // Static function used to access this class public static function get_instance() { if ( ...


-2

We got it working by changing the hook: add_action( 'wp_loaded', 'wp_html_compression_start' );


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' ) ); ?>


0

You can set the $_GET global internally. By saving the parameter passed as user meta and/or a cookie and retrieving it later. This would probably have to be put in your /wp-content/mu-plugins/ folder to work properly (so it is loaded early): <?php $parameter = 'theme'; // default for theme test drive $savemethod = 'both'; // 'usermeta' (only), ...


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.


-3

I have just discovered what the issue was. In my functions.php I was still calling my less.min.js, which was applying the style for some reason, removing that resolved my issue. Thanks!


0

I added after get_header(); ?> <aside id="secondary" class="left-sidebar widget-area" role="complementary"> <?php dynamic_sidebar( 'sleft' ); ?> </aside><!-- .sidebar .widget-area --> Then aside#secondary { width: 20%; float: left; margin-right: 15px; } Now... if you're going to have both ...


0

I have added pagination in order history page and it is working. Replace below code above loop $my_orders_columns = apply_filters( 'woocommerce_my_account_my_orders_columns', array( 'order-number' => __( 'ID', 'woocommerce' ), 'order-date' => __( 'Date', 'woocommerce' ), 'order-total' => __( 'Packages', 'woocommerce' ), ...


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


0

There is a Woocommerce setting to force SSL on the checkout page only. It's in Woocommerce > settings > checkout > Force secure checkout As a side note, and someone correct me if I'm wrong on this, but I've recently heard that it actually doesn't matter if the page is loaded over https as the only connection that has to be a secure ssl connection ...


0

In your functions.php you want to issue a call to set_post_thumbnail_size() https://codex.wordpress.org/Function_Reference/set_post_thumbnail_size As with add_image_size, you provide the target width, height & whether you want the image hard cropped to these dimensions. So, for example, set_post_thumbnail_size(427, 427, true); will crop all your ...


0

Wordpress HTTPS doesn't solely secure the site. It just allows a page/pages/sections to be forced to HTTPs. You still need a certificate. Our company uses Wordpress HTTPS in combination with an SSL certificate installed to the server. We also process through Authorize.net, and have not experienced issues (WP 4.4.2); though, we're still updating our theme to ...


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

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 ?>">


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


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.


0

include( plugin_dir_path( __FILE__ ) . 'ipn/paypal-ipn.php'); or define( 'PLUGIN_ROOT_DIR', plugin_dir_path( __FILE__ ) ); include( PLUGIN_ROOT_DIR . 'ipn/paypal-ipn.php'); or $plugin_dir_path = plugin_dir_path( __FILE__ ); include( $plugin_dir_path . 'ipn/paypal-ipn.php'); Note : to enqueu .css & .js files admin_enqueue_scripts inside plugin ...


0

The answer was found here: http://www.wprecipes.com/how-to-display-category-name-without-link For my purposes, I needed to define the category function and then call it by name-only inside the php echo: <?php $category = get_the_category($attachment->ID); echo 'html goes here'; echo ''.$category[0]->cat_name.'; ?>


0

Here is version for any post type, in case if you are using custom post type function has_children($post_ID = null) { if ($post_ID === null) { global $post; $post_ID = $post->ID; } $query = new WP_Query(array('post_parent' => $post_ID, 'post_type' => 'any')); return $query->have_posts(); }


0

You could create your own email_exists function to check it in a different way, I ended up doing this in a plugin as I was not getting consistent results with email_exists for some reason: function check_email_exists($email) { global $wpdb; $user_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM ".$wpdb->users." WHERE user_email = ...


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( ...


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 ( ...


0

Its wordpress feature to add <p> tags automatic, so that a non programmer who don't have knowledge of html tags also can publish posts/pages on wordpress. Wordpress arranges tags for them. However this feature also becomes trouble (In some cases) for programmers to set up pages. So there are 2 ways to handle this issue. First: ...


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 = ...


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


0

<?php $string = 'Sentence 1. Sentence 2? Sentence 3! Sentence 4... Sentence 5… Sentence 6! Sentence 7. Sentence 8. Sentence 9… Sentence 10... Sentence 11. '; $sentences_per_paragraph = 3; // settings $pattern = '~(?<=[.?!…])\s+~'; // some punctuation and trailing space(s) $sentences_array = preg_split($pattern, $string, -1, PREG_SPLIT_NO_EMPTY); // ...


0

@Dan meant this: <nav role="navigation" itemscope="itemscope" itemtype="http://schema.org/SiteNavigationElement"><?php wp_nav_menu([ 'container' => '', 'items_wrap' => '<ul>%3$s</ul>', ... ]); ?></nav>


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


0

You can change font size of header and paragraph text by editing/adding custom CSS to your stylesheet in Theme Root folder as (wordpress/wp-content/themes/your-theme/style.css). h1 { font-size: 24px;} h2 { font-size: 22px;} h3 { font-size: 18px;} h4 { font-size: 16px;} h5 { font-size: 12px;} h6 { font-size: 10px;} Hope it helps you.


0

You can edit your theme's stylesheet (style.css) to change the font size for each of the headings and the paragraph element to your liking. Then you can select the heading that fits your needs in your text editor. To do this most easily, hover over the "Appearance" tab in your WordPress Admin, click "Editor," select your "Stylesheet" (aka "style.css") from ...


0

Since your new theme doesn't register the shortcodes they're regarded as plain text. Any attempt at filtering is useless, because as far as WordPress is concerned they aren't shortcodes. The easiest way to solve this is to register the shortcodes in your new theme and hook them to an action that does nothing besides removing the shortcode.


0

try this add_filter( 'get_the_excerpt', 'strip_shortcodes', 20 ); or try this edit echo strip_shortcodes( get_the_excerpt() ); if shortcode is not register with wordpress function add_shortcode add_filter( 'the_excerpt', 'remove_shortcodes_in_excerpt', 20 ); function remove_shortcodes_in_excerpt( $content){ $content = strip_shortcodes($content); ...


-1

Try: $excerpt = $post->post_excerpt; $excerpt = apply_filters('the_content', $excerpt); echo $excerpt; Or: $excerpt = $post->post_excerpt; $excerpt = apply_filters('the_excerpt', $excerpt); echo $excerpt;


0

function wpsesess_ddecode_excerpt( $excerpt ) { return strip_shortcodes( $excerpt ); } add_filter( 'the_excerpt', 'wpsesess_ddecode_excerpt' ); EDIT Can you please post this in functions.php and let me know?


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


0

You can include or require other php files in your functions.php file or you could consider using a plugin. Plugins will run on any theme, so if this isn't what you want, you could consider some code in your plugin to check if your theme is active or not, such as: <?php $theme = wp_get_theme(); // gets the current theme if ('twentytwelve' == ...


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.


0

The classes are hardcoded in wp_generate_tag_cloud() function. Your only option there is to modify final string output via wp_generate_tag_cloud filter.


-1

The easiest way to get the site url without any sub-directories ( http://example.com/ instead of http://example.com/blog ), just use the backslash / For example, if you type: <a href="/">domain url</a> It will create a link that goes to your domain


0

It is a long question but it is possible for some developers I would like to give this answer. Example: I have two choose for my home layout Grid and List and I prefer Grid is default choosing. I should add default value in add_setting simple like this 'default' => 'grid'. $wp_customize->add_setting('yourtheme_home_layout_style', array( ...


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


0

I was having the same issue. Somehow I was able to resolve it by using the following plugin https://wordpress.org/plugins/anything-popup/ You can give popup title/link/image and in the content echo the shortcode of the form. and call the popup shortcode where ever the text/link/image is placed. On clicking any of these, popup with the required content will ...


0

No need for a routine here - use the WordPress hook system to "attach" a function that will run when a post is published: // https://codex.wordpress.org/Plugin_API/Action_Reference/publish_post function wpse_225371_post_published( $post_id, $post ) { // Do your thang } add_action( 'post_published', 'wpse_225371_post_published', 10, 2 );


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' ...



Top 50 recent answers are included