Hi team toolset!
In one of my view i need to have posts that are updated(modified) with their updated date (last modified descending).
i do not want that it shows all posts with column of post date set to ( last modified date) because in this case the post date and modified dates are same until posts is updated and i do not want such posts in the view.
i want only updated posts should be in the view with column showing their last modified date and the updated date will be greater than then posted date to get a "true" updated date.
I hope you got my problem so please provide any solution or custom code.
Regards
Les langues: Anglais (English )Espagnol (Español )
Fuseau horaire: Europe/London (GMT+01:00)
You can use a conditional shortcode to check if the post modified date is greater than the post published date (both of which you can generate with the wpv-post-date shortcode).
Here's an example I tried quickly on my local test site which worked as expected:
Hi Nigel !
Yes that condition shortcut is good . i tried this in loop items here lien caché and it binged out this results lien caché.
The result of shortcode seems perfect because it bringing out all the updated posts with their updated dates.
But i want your conditional shortcode to work in my table view in such way that it shows only updated posts with all these columns lien caché .
My table lien caché should have only updated posts with their updated date there in post date column with all other custom fields information.
Please help me to have all updated posts in this table.
I have added the short code around the whole row lien caché and it's giving fine result of updated projects sorted in last modified descending.
The problem is that after adding this shortcode it's not showing complete 50 projects according to the limit set to show 50 projects only.
i would like you to see inside if everything is settled up.
Les langues: Anglais (English )Espagnol (Español )
Fuseau horaire: Europe/London (GMT+01:00)
OK, the problem here is that the database runs a query to get 50 posts, and then we check each of them to see whether they pass the test for the modified date, and if they fail we don't output them, so you will end up with less than the original 50 posts.
If pagination is important, you would normally need to intervene before the query so that you specify the test within the query itself, so that the query returns 50 posts that already passed the test.
The problem here is that WordPress doesn't provide for modifying the query in such a way. (You can modify the query in all sorts of other ways, but not this.)
You would have to write a custom SQL query for this, and that's not something I can help you with, I'm afraid, you would need to recruit a developer for that.
Alright, i got your point and yes that's the reason we are getting less then 50 posts.
As my goal is to have only 50 most recently updated posts by setting limit to show 50 posts, No pagination.
If you wrap that condition in a query filter php function that executes earlier and bring out updated posts and then show us the 50 most recent updated posts out of them on our view ?
Les langues: Anglais (English )Espagnol (Español )
Fuseau horaire: Europe/London (GMT+01:00)
The alternative is to ditch the conditional shortcode and instead run some custom code using the wpv_filter_query_post_process API hook, which fires after the query has been run, but before Views outputs them.
So you can have the View with no pagination, so all possible results are returned.
Then use that filter to manually iterate over all the results and test them to see whether the post modified date is later than the post published date, removing any posts from the results that fail that test. Then only retain the first 50 such results.
Yes i understand and that will be the best option.
i would like to have that conditional filter wrapped in wpv_filter_query_post_process API hook from your side, Which will first filter the posts according to condition (modified date is later than the post published date) and then we can output the latest 50 results out of them.
Looking forward for the code from your side.
Thanks
I applied the code but its not working fine.
everything is setup according to the requirement.
No pagination. No limit. conditional code removed from the loop.
The problem comes when i do (no limit, no pagination) then the page showing related view does not work lien caché
Please take few moments and debug the problem inside. get my site access in private .
Your help will be really appreciated.