Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #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, 7 months ago by nickthe.
    #1300775

    Hey 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,
    Ismael

    #1300881

    Hi 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.

    #1301159

    Hi,

    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,
    Ismael

    #1301937

    Hi 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,
    Nick

    #1302285

    Hi,

    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,
    Ismael

    #1302389

    Hi 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

    #1302798

    Hi,

    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,
    Ismael

    #1303394

    Hi 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!

    #1303680

    Hi,

    Great, I’m glad that Ismael could help you out, and thanks for the update. I’ll go ahead and close this thread for now then, please open a new thread if you should have any further questions or problems.

    Best regards,
    Rikard

Viewing 10 posts - 1 through 10 (of 10 total)
  • The topic ‘Enfold latest portfolio widget publish time’ is closed to new replies.