How do I remove the inserted content every time I do a WP_Query()?

Home Forums Auberge How do I remove the inserted content every time I do a WP_Query()?

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #18849

    raymacz
    Participant

    How do I remove the inserted content every time I do a WP_Query()?

    Resolved

    Hi, I started using the Auberge with a child-theme (still in development):
    How do I remove this? screenshot

    My query:

    <div class="wpb-wrapper">
    	<?php
    		if (is_front_page()) {
    			$args = array(
    				'post_type'=> 'nova_menu_item',
    				'post_status' => 'publish',
    				'posts_per_page' => '10',
    				'order' => 'DESC',
    				'orderby' => 'date',
    			);
    			// the query
    			$queryz = new WP_Query($args);
    			// The Loop
    			if ($queryz->have_posts()) :
    				while ($queryz->have_posts()) : $queryz->the_post(); ?>
    				<div id="myproblem">
    				</div>
    				</div>
    				<?php endwhile;
    			wp_reset_postdata(); /* Restore original Post Data */
    			endif;
    		}
    	?>
    </div>

    Problem: Everytime I start a query (as shown above), It inserts & prints this screenshot So how do I fix it?

    I’ve been trying to fix this issue for more than 24 hours now, but to no success:
    So what do I put to my “functions.php” to remove the action/filter?

    function RBTM_my_func(){
      // what code?
      remove_action('parse_query',array('WM_Nova_Restaurant', "sort_menu_item_queries_by_menu_order"), 10);
    }
    add_action('init', 'RBTM_my_func', 10);

    Any help would be much appreciated… Thank you!

    • This topic was modified 4 months, 3 weeks ago by  Oliver Juhas. Reason: Formatting code
    #18855

    Oliver Juhas
    Keymaster

    Hi raymacz,

    Please understand that this question is out of scope of support service I provide – please read terms of service. I suggest hiring a WordPress developer that can help you with advanced theme modifications.

    Also, please note that I do not know what you are trying to achieve here.

    Why are you creating a new query for food menu? The theme already displays food menu on homepage as can be seen in theme demo website.

    It is not that easy to create custom food menu query, as Jetpack plugin modifies it anyway. That’s why there is that food section title and description.

    Also, I can see there are more closing </div> than opening ones in your code, which will break HTML.

    As for removing the Jetpack actions and filters, I suggest contacting Jetpack plugin support. They will be able to provide more help here. First, you can try rising the priority of your custom function in init hook from 10 to 100, for example.

    However, if you want to introduce a custom sorting of your food menu items, please note that this is easily done in WordPress admin by simply dragging and dropping the food menu items to place.

    Best regards,

    Oliver Juhas
    WebMan Design

    #18859

    raymacz
    Participant

    Thanks for the response & tip regarding the priority. I already asked this in WordPress Stackexchange & they said to contact the Theme developer support. I just wanted some basic filtering of the query & every time I do that, something just pops up in the content which is not common from other themes I experienced. I have no trouble with the querying itself, it is the content that gets inserted. Look we like your theme, we just wanted some basic querying filtering & customization, I am just asking for a little help here, that’s all. Thanks.

    #18863

    Oliver Juhas
    Keymaster

    Hi raymacz,

    I’m sorry but the StackExchange tip to contact theme developer support was just a tip. The code you are looking for is not present in a theme but in Jetpack plugin. Please understand this is not a theme issue.

    The output of food menu is being filtered via Jetpack plugin’s code. The theme only modifies the Jetpack output a bit fixing issues and introduce additional functionality. The whole output of food menu is Jetpack plugin related, not a theme one.

    What do you mean by “I just wanted some basic filtering of the query”? It would be easier for me to provide you with some help if I know specifically what you aim to do. Like I’ve mentioned, you can control the order of food menu items in WordPress admin easily by dragging and dropping them where you need.

    Try using this code instead to modify the food menu query to your needs:

    function child_theme_food_menu_query( $query ) {
    	if (
    		class_exists( 'Nova_Restaurant' )
    		&& ( isset( $query->query_vars['post_type'] ) && Nova_Restaurant::MENU_ITEM_POST_TYPE == $query->query_vars['post_type'] )
    	) {
    		$query->set( 'orderby', 'title' );
    	}
    }
    add_action( 'pre_get_posts', 'child_theme_food_menu_query' );

    Please understand that this is a custom theme modification and I do not provide support for those – please read terms of service. Please understand this is beyond free support I provide.

    Best regards,

    Oliver Juhas
    WebMan Design

    #18895

    raymacz
    Participant

    “filtering of the query” meant that I want to customize the querying of “nova_menu_item” CPT to other parts of the website, NOT just the Main Query of the Main Menu, which currently displays both:
    1. Front page (WP customizer)
    2. “Food Menu” Page (Attributes – Template)

    I know what you meant that this is caused by the Jetpack plugin.
    I got it when you said that it’s not a theme issue, however… somehow it puts limitations when setting up a custom query (new WP_Query) on other parts of the website (e.g. custom widgets) because Jetpack plugin inserts a certain content- Just my little feedback on your theme.

    To overcome our main problem, we found a way using Pods plugin to extend Jetpack’s CPT “nova_menu_item”. Now we can
    do custom queries (new WP_Query) anywhere on the website without issue.

    Nevertheless, I know your Auberge theme’s code is well written, that’s why we used it. The code that you gave me us a bonus for modifying the food menu query helped me in some way –
    we appreciate it a lot & thank you so much for that.

    As of this moment, everything has been resolved. May you have more success with your future projects. Thanks again for your response and effort.

    • This reply was modified 4 months, 3 weeks ago by  raymacz. Reason: spelling correction
    #18897

    Oliver Juhas
    Keymaster

    Hi raymacz,

    Thank you. I wish you a lot of success with your website too and I’m glad you’ve resolved your issue.

    however… somehow it puts limitations when setting up a custom query (new WP_Query) on other parts of the website (e.g. custom widgets) because Jetpack plugin inserts a certain content- Just my little feedback on your theme.

    I must repeat, please understand that what you were looking for is coming form Jetpack plugin, not the theme, so you can not blame the theme for Jetpack’s food menu output really. Jetpack plugin support would be more suited to provide help on how to modify the food menu WP_Query to your needs. I’ve done what I could to help with this matter. Please understand I can only provide support for software I create.

    Also, the theme actually allows you to display only partial food menus on “Food menu” page template when you define a specific food menu section, for example. But you can simply use a specific food menu section archive page for such cases too (as can be seen in theme demo website).

    Best regards,

    Oliver Juhas
    WebMan Design

    #18904

    raymacz
    Participant

    You have given us much help more than you possibly should, and we are grateful for that. I’m sure we are not mistaken for choosing your theme as part of our project as others do as well. I’m positive these tips will also help other people in the future. A big thumbs up mate… cheers!

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

You must be logged in to reply to this topic.