dozerua
Forum Replies Created
-
Forum: Developing with WordPress
In reply to: Quering array of post types & pagination@bcworkz
thank you for your help. Issue was found.Basically on my csv import or dummy posts ( I assume ) posts had only different dates while time was always same (12:00am). So if I have 10 posts posted at 11/11/2011 and at 12:00am all, on page reload wordpress was showing them in random order.
By making double filtering, for example ‘orderby’ => ‘date ID’, everything appears fine and no repeats.
I, actually, expected that wordpress makes it default but no ??Learned this lesson, now is fine with pre_get_posts() and also with query_posts().
Thank you again. I did articles manually and understood that time matters.
Forum: Developing with WordPress
In reply to: Quering array of post types & paginationOkay, thank you for your help so far.
Report is:
1) I tried on fresh wordpress setups on 2 different servers
2) No other plugins are enabled
3) The only piece of custom code is in functions.php (in 2020 parent theme)add_action( 'pre_get_posts', 'get_posts_search_filter' ); function get_posts_search_filter( $query ){ if ( $query->is_main_query() ) { $query->set('category__in', [ '1']); } }
4) I updated permalink, not sure if that could cause issues
5) Articles are shown on default wordpress posts page, which is set by default in “Settings” -> “Readings”Your homepage displays Your latest posts
What do I do now? Is it a problem with me?
Can you test it in your environment, please?For making dummy posts I used “Allimport pro plugin” before (with csv import) and for the most recent instance I used “WP Dummy Content Generator”, which was disabled after work was done. WordPress installation files are different (I tried on server’s installation option and tried uploading files from wordpress website).
In all cases articles are messed up. If I output everything (disable limit on amount of posts) then order is correct and no repeating articles.
Regards
Forum: Developing with WordPress
In reply to: Quering array of post types & pagination@bcworkz I tried on many new instances. This is literally 2020 template, main page. The only custom code added is pre_get_posts() to functions.php
Nothing custom.
So tonight I did other fresh wordpress setup, added 100 dummy posts with plugin.
Posts appear fine if no pre_get_posts() set.If I add filter, pagination gets messed up. Cache is disabled on server. And website shows different articles on every page reload.
https://posts.placemeonline.com/
Check it please.
I tried in private tab.
Functions.php has this text:add_action( 'pre_get_posts', 'get_posts_search_filter' ); function get_posts_search_filter( $query ){ $query->set('category__in', [ '1']); }
Wordpress is 6.0.3
Forum: Developing with WordPress
In reply to: Quering array of post types & paginationI tried “pre_get_posts” on default posts page (literally set some page to be posts page in settings), set my own parameters and results are still messed up.
add_action( 'pre_get_posts', 'get_posts_search_filter' ); function get_posts_search_filter( $query ){ if ( $query->is_main_query() ) { $query->set( 'post_type', [ 'post', 'blog' ] ); $query->set( 'ignore_sticky_posts', '1' ); $query->set('status', 'publish'); } }
Also I noticed that results are messed up even if I try to do array of categories in that query.
What can be an issue?
I did clean fresh setup on subdomain, imported posts which I have with default wordpress importer, modified pre get posts, check results – messed up.
What is going wrong?
Regards
Forum: Developing with WordPress
In reply to: Quering array of post types & pagination@bcworkz , thank you for your answer.
I am not sure what can be hard for wordpress if initially I request only post type, sorting, page, posts per page.
I assume that is basic request. I even tried to get_posts with just post types and paged.
But I will try modyfing main query. Not sure if that will help.
Forum: Plugins
In reply to: [Redirection] Redirect links with WeglotHello John, sorry for late response.
I added this to .htaccess
Redirect 301 "/de/tag/economy/" "https://www.website.com/de/tag/sustainability/"
And in plugin is set
301 /tag/economy/ https://www.website.com/tag/sustainability/
now when I hit
https://www.website.com/de/tag/economy/
I get redirected to
https://www.website.com/de/tag/sustainability/And when I hit
https://www.website.com/tag/economy/
I get redirected to
https://www.website.com/tag/sustainability/If you can explain how to achieve this completely via plugin, I would appreciate that.
Before editing .htaccess both links were in plugin and were redirecting me to single
https://www.website.com/tag/sustainability/Forum: Plugins
In reply to: [Redirection] Redirect links with WeglotUPD: I managed to set redirects with”/de” directly in htaccess and non “/de” in plugin. All works. But it is not a solution as I can’t track clicks on urls with “/de”..