WP Query with custom Shortcode

There are few issue with your code When using WP_Query in conjuction with the_post() or using get_posts() in conjuction with setup_postdata( $post ), you need to reset the $post global with wp_reset_postdata(), not wp_reset_query(). wp_reset_query() is used in conjuction with query_posts() which you should never ever use You would want to reset posdata between your … Read more

WordPress Search Results for Multiple Post Types

The wp_get_attachment_image_src() function expects you to also pass some kind of attachment ID plus it doesn’t grab the image HTML that we need so instead we should use wp_get_attachment_image(). IF a post has a post thumbnail, grab it.ELSE IF the post has any attached images, grab the first one.ELSE maybe show a placeholder? I’ve defined … Read more

Search query -> Show all pages except certain template

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 … Read more

How to change wordpress dates to native language (even if the languge not available i wordpress)

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 … Read more

WP_Query Not Recognizing Taxonomy Parameter in Custom Search

The better option may be to use the pre_get_posts hook instead to modify the query before it gets requested instead of creating your own query. Here’s what it would look like: /** * Modify Theme Queries * – https://developer.wordpress.org/reference/hooks/pre_get_posts/ * – https://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts * * @param $query * * @return void */ function theme_pgp( $query ) … Read more

Custom URL going to 404

Redirect early First of all, your redirect function should be hooked early: you are not relying on query variables there, so you could use init hook: function search_redirect() { if (!empty($_GET[‘s’])) { $home = trailingslashit(home_url(‘catalog-of-work’)); wp_safe_redirect($home.urlencode(get_query_var(‘s’))); exit(); } } add_action(‘init’, ‘search_redirect’); The reason is that this will redirect the request much earlier, saving a lot … Read more

How can I remove the search window?

I searched through all the files in the theme for the word “search” and tried removing that command from entry.php and entry-summary.php. None of that had an effect. I also tried removing the search.php file, that had no effect. To save you grief, any edits to the core files provided by WordPress will potentially break … Read more