Site logo

[Resolved] Show latest posts on 404 page with php

Home Forums Support [Resolved] Show latest posts on 404 page with php

Home Forums Support Show latest posts on 404 page with php

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #2524364
    René

    Hello,
    how can I edit the content-404.php to show the most recent posts after the search bar? In the same style as on the archive pages. Is there maybe a shortcode or method i can use?

    Code

    #2524480
    David
    Staff
    Customer Support

    Hi there,

    why not just use a GP Block Element, to create your own 404 template, and then use a GB Query Block or the Core Latest posts block to display the posts ?

    Otherwise you will need to create a custom loop in PHP.

    Let me know

    #2524494
    René

    The file should be easy to pack into the child theme. So I want to solve this with php. Can I create such a custom loop quickly? I tried this: https://davidsutoyo.com/articles/how-to-use-the-wordpress-loop-for-custom-post-types/

    #2524511
    René

    I found a good tutorial. I’ll look at that first.: https://www.youtube.com/watch?v=rw3jRE8IslM

    #2525669
    David
    Staff
    Customer Support

    Glad to hear you found something you can use.

    Your alternative would be to look at the themes archive.php and use that as a basis for your child theme 404 template. As that already has a loop for you to work with.

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.