Skip Navigation

[Resolved] How to get post publication date

This support ticket is created 7 years, 4 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 10:00 - - - - -
- - - - - - -

Supporter timezone: Africa/Cairo (GMT+02:00)

Tagged: 

This topic contains 12 replies, has 2 voices.

Last updated by Mohammed 7 years, 3 months ago.

Assisted by: Mohammed.

Author
Posts
#470835

Hello,
I need the post publication date to :
1- Add a filter based on date (for instance "show all posts published after this date" ;
2- Insert the post publication date into a loop or specific view.
How should I set that up ?
Thank you.

#471014
Edit View ‹ replicate — WordPress - Google Chrome 2016-12-26 16.05.27.png
Edit View ‹ replicate — WordPress - Google Chrome 2016-12-26 16.00.44.png

Hello,

I’m Mohammed: the Toolset support team leader. I’ll give my best to help you to achieve your needs through Toolset components.

You can filter by the post publishing date with many options and also you can display the post publishing date in the page.

For this, you will need to activate the Toolset Views plugin

The following steps will guide you to achieve your requirements.

<<Filtering by post date>>
- In your admin dashboard, go to Toolset > Views , then, click "Create new View"
- Give the view a name and scroll dow to the "Query Filter" section and click "Add a filter"
- Select the post date as described in the attached screenshot
- You will see many options, configure them according to your needs.

<<Displaying the post date>>
- Scroll down in your View to the "Loop Output Editor"
- Click "Fields and Views" button
- Click post date like described in the attached screenshot
- Save the View and add it to a page and test if it works.

I'm waiting for your reply.

Thanks.

#471072

Hello and thank you for your awnser,
I managed to display the post date in posts ok. Thank you.
But I still can't see how to display the post date as filter. In deed, the screenshot you sent doesn't at all look like what I get : I have a textbox where to add filters. And when I try to add a new filter by clicking the button "new filter", I got a list of filters including only "custom fields" and not the standard fields, where I assume there is the post date...
Thank you.

#471089
query filter.png

Hi Roma,

-In the view edit page, you will find a section "Query Filter".
-In this section, you will see a button "Add a filter" , this will generate a popup that asks you to select the field
- Select the field and click "Add query filter", then configure the filter.
-Please see the attached screenshot and this video: hidden link

Thanks.

#471106
capt1.JPG

In the view edit page, I don't have "query filter" section. I only have a "filter editor" section, where I must set shortcodes to insert my filters. Above it, there is a toolbar where there is in deed the "new filter" button, but as I said before, it contains only "custom fields".
Thank you.

#471109
Edit View ‹ replicate — WordPress - Google Chrome 2016-12-27 00.00.45.png

Hi,

This depends on the configurations you choose while creating the post.
Please try to create a new view but this time, after clicking "Add new Views" , select the "Display all results" option from the popup.

OR, you can display the query filter in an existing View by clicking on the "screen options" arrow at the to right of the page and activate the "query filter" section.

Please check the attached screenshot.

Thanks.

#471112

Oh. I think I understand what's the trouble now : I am looking to add a front-end filter, not a query filter. But the way you are saying it looks like it's only query filters ? Or am I still missing the point ?

#471113

What I meant is I need to display the date filter on front-end.
Basicaly, the user must set if he wants to see :
- last 24h posts ;
- last 48h posts ;
- last week's posts ;
- last month's posts...

Thank you !

#471358

Hi,

Unfortunately, this is not supported by Views.
If you have a programming background, you can workaround this by adding the filters you need in the filter editor and customize the query manually.

You may add a select menu to the filter editor to choose the time interval like the following:

<select name="timeinterval">
<option value="1">last 24h posts</option>
<option value="2">last 48h posts</option>
<option value="3">last week's posts</option>
<option value="4">last month's posts</option>
</select>

The, in your theme functions.php file, you can use this filter to customize the query that fetches the posts from the database:

wpv_filter_query

Reference: https://toolset.com/documentation/user-guides/views-filters/

If you need help to achieve this, you may consult one of our certified partners to develop a solution for you: https://toolset.com/consultant/

Thanks.

#471549

Hello and thank you very much, I see we're getting closer.

In query filter, if I set "published date = after or equal" and then set "PAST" = "5", the querry works and show only the 5 last days' posts.

Then, I see it's possible to change "PAST" to "URL parameter" or "shortcode attribute". So I understand it's possible to insert the "5" into a custom parametric filter ? Isn't it ?

Therefore, I could have the select box with values 1, 2, 7 and 30, which, being modified by the user, would modify the filter ?

Does it make any sens ?

#471720
Edit View ‹ replicate — WordPress - Google Chrome 2016-12-29 10.11.17.png

Hi Roman,

In case that I understand you well. I think yes.
You can get the year, month values from shortcode attribute or a URL parameter.
Please check the attached screenshot.

Thanks.

#471904

Hello and thank you,
How should I fill the select in order to tell the query where to find the number of days ?

<select name="timeinterval" url-parameter="timeinterval">
<option value="1">last 24h posts</option>
<option value="2">last 48h posts</option>
<option value="7">last week's posts</option>
<option value="30">last month's posts</option>
</select>

Thank you very much !

#472051

Hi Roman,

I think that you already shared the right way in your previous reply.

Do you want to generate it based on specific criteria?

Thanks.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.