New answers tagged

1

to use a translation not finished yet, click on "Export" here : https://translate.wordpress.org/projects/wp/dev/si/default . And save the files as si.po and si.mo in the directory wp-content/languages (choose the extension in the dropbox menu) If there is word missing, you can use Podedit to edit the file and you can also propose your word in the tool ...


1

You can enforce a post type per callback on pre_get_posts: is_admin() || add_action( 'pre_get_posts', function( \WP_Query $query ) { $post_type = filter_input( INPUT_GET, 'post_type', FILTER_SANITIZE_STRING ); if ( $post_type && $query->is_main_query() && $query->is_search() ) $query->set( 'post_type', [ $post_type ...


0

You're essentially running the same query twice, instead of looping over a second query, why don't you loop over $wp_query? $types = array(); if( have_posts() ) { while (have_posts()) { the_post(); if ( empty( $types[$post->post_type] ) { $types[$post->post_type] = 0; } $types[$post->...


2

It's a little hard to think in meta_query code for complicated case like this and without access to data. :) What you have working can be expressed as two following conditions: start_date BETWEEN event_begin and event_end end_date BETWEEN event_begin and event_end Your first case with both in between seems irrelevant, since these two will catch it ...


0

Here is what worked for me. Preethis answer almost got there, but no data was getting set. I needed to find a way of accessing the data in the array, and I used implode to do it. So here is my final code that enabled me to create a search form that loops and displays categories, allows the user to do a keyword search via any number of categories, and ...


1

let’s start by defining an HTML search form: <form method="get" action="<?php bloginfo('url'); ?>"> <fieldset> <input type="text" name="s" value="" placeholder="search&hellip;" maxlength="50" required="required" /> <p>Refine search to posts containing chosen tags:</p> <?php // generate list of categories $tags = ...


0

While the pre_get_posts filter is going to let you modify the main query before it happens, letting you add extra requirements, in this case it isn't necessary! You can do it all with the URL and the search form First, the query variables passed into WP_Query can be used in the URL. post_parent being the query var you're wanting. So if we have this: <...


2

You can use pre_get_posts filter to filter out what you need. There's an example on how to do this in Codex: https://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts#Exclude_Pages_from_Search_Results function search_filter($query) { if ( !is_admin() && $query->is_main_query() ) { if ($query->is_search) { $query->...


0

You can add more than one filter call, so each of your custom meta_key's can be handled in separate code and when executed will cumulatively adjust the query. Perhaps look at the pre_get_posts filter rather than parse_query (although the solution I'm suggesting could possibly work in either case). pre_get_posts gives you access to the current query before ...


0

Use the get_search_form filter: add_filter('wp_nav_menu_items','add_search_box_to_menu', 10, 2); function add_search_box_to_menu( $items, $args ) { if( $args->theme_location == 'primary' ) return $items. get_search_form(); return $items; } add_filter( 'get_search_form', 'custom_search_form' ); function custom_search_form( $form ) { ...


1

REWORKED ANSWER TO ANSWER THE QUESTION In order to exclude all pages with a certain template, all you need to do is to run a meta_query to exclude all pages with the custom field _wp_page_template set to bedankt. Remember, WordPress saves the template assigned to a page as a hidden custom field called _wp_page_template With this in mind, we can do the ...


1

As discussed in the comments, your database prefix settings are off-kilter. Check the database prefix actually in use in your database, and make sure it's the same as the one in wp-config.php. Also make sure all of your WordPress-related tables have the same prefix. You'll also need to search through your database, particularly in the _options table, as ...



Top 50 recent answers are included