Add a data attribute to list item element in menu

Looking to add a data attribute to a list item in a menu, I can see that some threads on here can add it to the actual <a> link tag, I am looking to add it to the list item itself <li> So this code adds the attribute to the <a>tag add_filter( ‘nav_menu_link_attributes’, ‘themeprefix_menu_attribute_add’, 10, 3 ); function themeprefix_menu_attribute_add( $atts, $item, $args ) { // Set the menu ID $menu_link1 = 20; // Conditionally match the ID and add the attribute and value if ($item->ID == $menu_link1) { $atts[‘data-content’] =…

Previewing/Updating some Pages causes "The requested URL was rejected" Error

The wordpress site is suddenly having a problem where on some (not all) of the pages, when you click preview page or update changes it gives an error message: « The requested URL was rejected. If you think this is an error, please contact the webmaster. Your support ID is: 9641638102880218190″ This can be circumvented by entering the preview url directly into the browser or clicking « open in new tab » when you click the preview button. However you cannot right click and do this on the « Update » button so it does…

Query posts by meta value and sort by another meta key

I would like to query and sort posts by meta key « popularity » and these posts must have also another meta key « gone » with value « 1 » to query $args = array( ‘post_status’ => ‘publish’, ‘posts_per_page’ => ‘150’, ‘cat’ => $cat_id, ‘order’ => ‘DESC’ ‘meta_query’ => array( ‘relation’ => ‘AND’, ‘popularity’ => array( ‘key’ => ‘popularity’, ‘orderby’ => ‘meta_value_num’, ), ‘be_price’ => array( ‘key’ => ‘gone’, ‘value’ => ‘1’ ) ) ); Source: https://wordpress.stackexchange.com/feeds

Excluding pages in WP_query using ACF

I have a custom loop for showing child pages of the current page, but I’d like to allow the WP user to enter page IDs to be excluded from the loop, using Advanced Custom Fields. My current loop is as follows. It almost works, except it only excludes the first page ID in the list: <?php $exclude_ids = get_field(‘exclude_pages’); $args = array ( ‘post_type’ => ‘page’, // custom post type ‘post_parent’ => $post->ID, ‘orderby’ => ‘menu_order title’, ‘order’ => ‘ASC’, ‘posts_per_page’ => -1, ‘post__not_in’ => array( $exclude_ids ) );?> And…

Woocommerce Minimum Price for a Composite Product to add in cart

I’m making a composite product in Woocommerce, where users can select which products they can choose (like a customized box). I just want that the minimum price to order this composite product should be Say « x ». How do i enable that? I have a code but that will check the overall cart value. How do i do it for this one individual product add_action( ‘woocommerce_checkout_process’, ‘wc_minimum_order_amount’ ); add_action( ‘woocommerce_before_cart’ , ‘wc_minimum_order_amount’ ); function wc_minimum_order_amount() { // Set this variable to specify a minimum order value $minimum = 50; if (…

301’s not working with multisite

I had moved over my website a few months ago from a normal WordPress install to a multi site install. It’s obvious that 301 redirection is something that needs to be set up with a new site after you create properly named pages and you want the old to redirect to the new, so I know I set this up. However, now I’ve used a couple different plugins over the last while, checked my .htaccess file, and no matter the plugin I use or the updates I do makes it…

How to change parent permalink?

I have a theme with hardcoded permalink structure for some posts. Those posts open with site.com/parent/page structure. I created a filter that replaces the link from « site.com/parent/page » to « site.com/newparent/page » in functions.php with: add_action(‘init’, ‘change_slug_of_post_type_parent’, 20); function change_slug_of_post_type_parent() { $args = get_post_type_object(« parent »); $args->rewrite[« slug »] = « newparent »; register_post_type($args->name, $args); } Links are now generated OK, but when I click on them, the page doesn’t load. Can someone please help? I am sure this is easy fix, but I cant get around it. I am new to wordpress programming (I used GSCMS, and CMSGS…

Alter query using pre_get_posts() if meta_key is present

I am trying to modify the number of posts per page for archive pages that contain category sticky posts (added by the Category Sticky post plugin) to do so I am using the pre_get_postshook and have tried the following : add_action( ‘pre_get_posts’, ‘my_set_category_posts_per_page’ ); function my_set_category_posts_per_page( $query ) { global $wp_the_query; if ( ‘category_sticky_post’ === $query->get( ‘meta_key’ ) && ! is_paged ) { $query->set( ‘posts_per_page’, 8 ); } return $query; } I var_dump($query) I do get [meta_key] => category_sticky_post in the query_vars but I can’t sort out how to use…

Web Design Weekly #256

Headlines Responsive Images – Client Hints Jason Grigsby dives into the details on how to go about using Client Hints to help with the day-to-day task of creating responsive images. If you have never taken the time to investigate Client Hints this is a great primer. (cloudfour.com) Why I believe GraphQL will come to replace REST GraphQL sure is gaining more and more momentum in the developer community and in this post Martijn Walraven shares his thoughts about why he believes GraphQL will eventually replace REST. (dev.to) Yarn: A new…