Tagged: portfolio widget
-
AuthorPosts
-
May 14, 2021 at 2:32 pm #1300332
Hey Team,
I would like some help with the portfolio widget, I would like the latest moves located on the bottom footer of the page ιn Private Data
to show the most recent published post and not the most recent date as it is it showing now. For example if i go to an old portfolio job on the site and update it i would like that to show on the latest jobs section and not the most recent date.Please help if possible!
Thanks in advance.- This topic was modified 3 years, 6 months ago by nickthe.
May 17, 2021 at 4:09 pm #1300775Hey nickthe,
Thank you for the inquiry.
This is possible, but we have to make a new instance of the portfolio widget and create our own query. To do that, try to add this code in the functions.php file.
// https://pastebin.com/eV2wigYu
We added the new query here.
$this->avia_new_query = array( "posts_per_page"=>$count, 'date_query' => array( 'column' => 'post_modified', ),'tax_query' => array( array( 'taxonomy' => $this->avia_term, 'field' => 'id', 'terms' => explode(',', $cat), 'operator' => 'IN') ));
And use the date_query parameter to fetch the portfolio items based on the date they were modified.
'date_query' => array( 'column' => 'post_modified', ),
More info here.
// https://developer.wordpress.org/reference/classes/wp_query/#date-parameters
The new name of the widget is “Movers Latest Portfolio”. If you want to change it, just look for this line.
WP_Widget::__construct( 'portfolioboxnew', 'Movers Latest Portfolio', $widget_ops );
Best regards,
IsmaelMay 18, 2021 at 8:16 am #1300881Hi Ismael,
Thanks for the quick response. I tried your suggestion and yes the code did create a new widget area called ‘Movers Latest Portfolio’ and i replaced the widgets on the footer and sidebar with the new widget. I tried to test it by updateing an old post but unfortunetly it did not work. On the private area i will give you the link for the portfolio page i updated so you can have a look.
Any other solutions?
Thanks for your time.May 19, 2021 at 9:34 am #1301159Hi,
Thank you for the update.
Which of the portfolio items should display first in the widget, or which one did you modify last? Please post the login details in the private field so that we could check it properly. Make sure that the Appearance > Editor panel is accessible.
Best regards,
IsmaelMay 24, 2021 at 9:15 am #1301937Hi Ismael,
Thanks again for the fast response time. I’m happy to let you check it out, I have the logins in the private area.
Regards,
NickMay 25, 2021 at 8:22 pm #1302285Hi,
Thank you for following up.
We added the orderby parameter in the new query.
$this->avia_new_query = array( "orderby" => "modified", "posts_per_page"=>$count, 'date_query' => array( 'column' => 'post_modified', ),'tax_query' => array( array( 'taxonomy' => $this->avia_term, 'field' => 'id', 'terms' => explode(',', $cat), 'operator' => 'IN') ));
We tested and confirmed that it is working by editing the REMOVALISTS RED HILL SOUTH portfolio item. We also deactivated the cache plugin and the file compression settings temporarily. Please enable them back after checking the widget.
Best regards,
IsmaelMay 26, 2021 at 10:25 am #1302389Hi Ismael,
The back end of the site became very slow, after you added the orderby parameters query. I have removed the code for now because it did not work the way i wanted and also issue with the speed, when i removed the code it went back to normal speed
The code did half of the job im trying to achieve, it brang the last modified page first but it show the old publish date. So now when i post latest moves it shows the date it was published and not the date it was last modified that i would like it to show.
So the issues now are two, firstly with the code the whole back end became very slow and secondly the published date was showing and not the last modified date that i wanted.I have saved your code if you need it.
Thanks
May 28, 2021 at 11:21 am #1302798Hi,
it show the old publish date
If you want to display the modified date instead of the published date, try to edit the following line.
echo "<span class='news-time'>".get_the_time($time_format)."</span>";
Replace the get_the_time with the get_the_modified_date function.
// https://developer.wordpress.org/reference/functions/get_the_modified_date/
Unfortunately, we are not sure why adding the orderby parameter would affect the site speed. Try to remove the date_query or replace the whole query with the following code.
$this->avia_new_query = array( "orderby" => "modified", "posts_per_page"=>$count, 'tax_query' => array( array( 'taxonomy' => $this->avia_term, 'field' => 'id', 'terms' => explode(',', $cat), 'operator' => 'IN') ));
Best regards,
IsmaelJune 1, 2021 at 12:00 pm #1303394Hi Ismael,
Thanks alot the code worked perfect! No issues with the site speed.
You can mark the ticket as solved!Thank you for the help!
June 3, 2021 at 4:34 am #1303680 -
AuthorPosts
- The topic ‘Enfold latest portfolio widget publish time’ is closed to new replies.