Duplicates with WP_Query loop

It is quite hard to properly answer your question with the amount of context in your question, but I am going to try to use the context from your previous question Having a bit more context here on template, and if I read this correctly, this is on your index.php, I still believe and stand …

Read more

JavaScript, best way to use data from the loop

You can use WP_Query to get almost any post data out of your WordPress install. $sub_pages = new WP_Query( array( ‘post_parent’ => 3, ‘post_type’ => ‘page’ ) ); print_r($sub_pages->posts); This would get you the following: Array ( [0] => WP_Post Object ( [ID] => 94 [post_author] => 1 [post_date] => 2015-08-20 11:19:27 [post_date_gmt] => 2015-08-20 …

Read more

Displaying Only Certain Tags in Loop

Create a must-use plugin. Put it in <docroot>/wp-content/mu-plugins/selective-posts.php Following should be the code in selective-posts.php to filter specific posts. function golfclubs_tag( $query ) { if ( $_SERVER[‘HTTP_HOST’] === ‘www.golfclubreviewdomain.com’ ) { $query->set( ‘tag’, ‘golfclubs’ ); } } add_action( ‘pre_get_posts’, ‘golfclubs_tag’ ); This way it would filter all the queries across the site for specific domain …

Read more

How can I add a specific, custom widget to my theme’s header.php?

The WordPress codex mentions you should call the Widget Class name. Could it be that openingTimesWidget is a function instead of a Class? Following the WP Class naming convention your class would be written like this Opening_Times_Widget. https://codex.wordpress.org/Widgets_API Another possible reason that the widget is not displaying could have to do with the way your …

Read more

Translating add to cart woocommerce button [closed]

What is the content contained within your add-to-cart.php file template override? It should be similar to this: global $product; echo apply_filters( ‘woocommerce_loop_add_to_cart_link’, sprintf( ‘<a href=”https://wordpress.stackexchange.com/questions/218348/%s” rel=”nofollow” data-product_id=”https://wordpress.stackexchange.com/questions/218348/%s” data-product_sku=”https://wordpress.stackexchange.com/questions/218348/%s” data-quantity=”https://wordpress.stackexchange.com/questions/218348/%s” class=”button %s product_type_%s”>%s</a>’, esc_url( $product->add_to_cart_url() ), esc_attr( $product->id ), esc_attr( $product->get_sku() ), esc_attr( isset( $quantity ) ? $quantity : 1 ), $product->is_purchasable() && $product->is_in_stock() ? ‘add_to_cart_button’ …

Read more

How to get all existing post types

Thanks to @mmm The solution in this case is pretty simple. Just pass an empty $args array. Then it neglects the default ‘_builtin’ Example $get_post_types = get_post_types( $args = array(), $output, $operator ); return $get_post_types;

Validate a users email address when using gmail to register

Hmm, should try harder before asking for help 🙂 Was quite simple in the end (right or wrong) it works: $domain_array = array(‘googlemail.com’,’gmail.com’); $validemail = is_email($email_to_check); $exists_text=””; if ($validemail): $exists = email_exists($email_to_check); list($user, $domain) = explode(‘@’, $email_to_check); if (!$exists): if (strpos($user, ‘+’)) { list($username_email, $crap) = explode(‘+’, $user); $exists = email_exists($username_email . ‘@’ . $domain); …

Read more