New answers tagged

0

Complementing @Marcus Downing answer, I've added a protection to prevent deleting the tables when deleting a MU site. Be careful using this on production, I'm writing this while I develop, it's not widely tested. <?php /** * Plugin name: Shared Taxonomies for Multi-site * Version: 0.1 * Plugin Author: Marcus Downing, Lucas Bustamante * Author URI: ...


1

A few changes to your code: Changed the action hook to wp_head. Removed the false 'pluggable' wrapping of your function. if ( ! function_exists( 'post_is_in_descendant_category' ) ) { function post_is_in_descendant_category( $cats, $_post = null ) { foreach ( (array) $cats as $cat ) { // get_term_children() accepts integer ID only ...


0

An Example. A post for a game. People just comment the game. I wanna to have 3 types of comments. Comments form team A - comments for Team B and comments for the referee. This way all the comments are not mixed up. The hard way If I were to undertake such a project, my first instinct would be to define three custom post types. Team A, Team B, and Referee. I ...


0

⚠️ Temporary workaround https://stackoverflow.com/a/59109698/15497563 sudo apt-get install nginx-extras nginx.conf https://stackoverflow.com/a/11170826/15497563 http { # Include the perl module perl_modules perl/lib; # Define this function perl_set $uri_uppercase 'sub { my $r = shift; my $uri = $r->uri; $uri = uc($...


0

did you try a solution like this Include custom post type in "all posts" - Custom Post Types must be included in the main_query first - to be available in the loop output.


1

The concrete problem here is that you are trying to nest echo statements. That is not valid PHP. But the underlying problem is something you can see too often in WordPress templates: overly complex strings at the cost of readability. Here is an alternative style to get your output that is much easier to read. And you can use that everywhere in your templates....


0

Here is simple solution for it. $product_object = wc_get_product( $product_id ); echo '<a href="' . esc_url( $product_object->add_to_cart_url() ) . '" class="buy-now button">' . esc_html__( 'Buy Now', 'text-domain' ) . '</a>';


1

It may helpful to you... $video = (in_category ( 42 )) ? 'has-video' : ''; echo '<section id="cooked-recipe-list-' . $list_id_counter . '" class="cooked-clearfix cooked-recipe-' . $list_style . ' cooked-recipe-loader' . ( in_array( $list_style, $masonry_layouts ) ? ' cooked-masonry' : '' ) . ( isset($atts['columns']) && $atts['...


1

On a category archive page, you can use get_queried_object() to get the data of the current category in the main request, and get the slug like so: get_queried_object()->slug.


2

Simply add this code to functions.php file add_action ( 'category_add_form_fields', '___add_form_field_term_meta_text' ); function ___add_form_field_term_meta_text() { ?> <div class="form-field custom_image_upload"> <label for="tag-description">File Upload</label> <img src="" style=...


0

You may have already solved this months ago, but I here's my 2 cents as I thought this was an interesting question. I don't think the standard WP search query can be used to search for posts with either (post type A) or (post type B and category C). But you could pass a custom where clause to the query with posts_where filter to handle this kind of case. I ...


0

You'll want to hook onto the wp_insert_post action. Once the new post is created, you can then assign it to the taxonomy/term you wish. It might look something like this: add_action('wp_insert_post', function($postId, $post, $updatingExisting) { if( $updateExisting ) return; // read up on these params at http://developer.wordpress.org/...


2

Here's how you get all top-level categories and loop them to create a list of links, $parent_categories = get_categories( array( 'fields' => 'id=>name', // other term data no needed here 'parent' => 0, )); $parent_category_links = array(); foreach ($parent_categories as $parent_category_id => $parent_category_name) { $...


1

You could use the wp_insert_comment action to detect when new comments are added to a post. Then on your action callback, you'd the post's comment count with get_comments_number(), and change post categories with wp_set_object_terms(). Something along these lines, add_filter( 'wp_insert_comment', function($id, $comment) { if ( (int) $comment-&...


1

It looks like you're not passing the shortcode attributes to the query arguments at all. Also the arguments array structure a bit wonky. The WP_Query parameter docs is your friend when creating a custom query. Your shortcode should also return its output to show anything. Here's a modified version of your code that should point you in the right direction. ...


Top 50 recent answers are included