Home Forums WoodMart support forum “Hide Parent” Option Blocking WordPress API Access

“Hide Parent” Option Blocking WordPress API Access

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #631333

    furkanjtl2000
    Participant

    Problem Description:
    The “Hide Parent” option has been activated in the Woodmart Theme to hide parent articles/products in the frontend. While this functionality works as intended in the frontend, an undesired side effect has been identified:

    The activated “Hide Parent” option also blocks API access in the backend. As a result, the parent articles/products are also hidden in the WordPress REST API, which impacts backend functionality.

    Technical Details:
    – Theme: Woodmart
    – Affected Feature: Hide Parent Option
    – Impact: Blocking of WordPress REST API for parent products
    – Backend Integration: Active API usage for product management

    Desired Behavior:
    The “Hide Parent” option should exclusively influence frontend behavior and control visibility in the shop. The WordPress REST API should maintain full access to all products, including parent products, to ensure proper backend functionality.

    Question:
    Is there a way to modify the “Hide Parent” function so that it only affects frontend behavior while maintaining unrestricted API functionality in the backend?

    Please review and provide suggestions for resolving this issue.

    #631413

    Artem Temos
    Keymaster

    Hello,

    Try to add the following PHP code snippet to the child theme functions.php file to disable this feature in API requests

    		add_filter( 'posts_clauses', function ( $clauses, $query ) {
    			if ( ! empty( $query->query_vars['woodmart_single_variations_filter'] ) && wp_is_serving_rest_request() ) {
    				$query->set( 'woodmart_single_variations_filter', false );
    			}
    
    			return $clauses;
    		}, 90, 2 );

    Kind Regards

    #632313

    furkanjtl2000
    Participant

    Seems like its working now, thank you u can close this ticket

    #632329

    Artem Temos
    Keymaster

    You are welcome. Feel free to contact us if you have any further questions.

Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘“Hide Parent” Option Blocking WordPress API Access’ is closed to new replies.