Support » Developing with WordPress » preview all portfolio pages on 1 page

  • L.S.

    Thank you for reading this post. It seems if reached my limits of comprehending wordpress. I would like to achieve the following:

    My website contains a lot of pages representing our portfolio. For usability purposes i would like to show an image and title of all those individual pages on one ‘portfolio’ page.

    Basically i want to mimic the jetpack portfolio plugin, but then for all the pages i created before using the jetpack plugin.

    Strategy wise: I could copy and rename the jetpack-portfolio.php and tweek it into my needs. Which, i guess would only require a different query. How would i hook it into wordpress ?

    Secondly: a new function in my functions.php. But it doesn`t seem to be in the right place as then my functions.php gets bloated.

    Third: A plugin. Who knows which one fits my needs ?

    Kind regards,

    Dennis

    • This topic was modified 1 week, 5 days ago by destmedia.

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • If you’re using WordPress’ default block editor, you can simply create a page in the dashboard, use the QUERY LOOP block to fetch all the relevant pages, and style the page to your heart’s desire — all in the block editor, without writing a line of code.

    If you’re still on the Classic Editor or you simply prefer to do things the hard way (lol), then…

    Strategy wise: I could copy and rename the jetpack-portfolio.php and tweek it into my needs. Which, i guess would only require a different query. How would i hook it into wordpress ?

    I don’t know what’s in the jetpack-portfolio.php file: perhaps it’s creating the “Portfolio” custom post type and that’s not what you want.

    Instead, you should create a custom page template in your theme directory. See: https://developer.wordpress.org/themes/template-files-section/page-template-files/

    Good luck!

    Thread Starter destmedia

    (@destmedia)

    Dear George,

    Thank you for your reply. As i had never used the query loop block, it`s definitely usefull. I now consider adding a page containing all blog posts.</p> <p class=””>What i`m missing in the query loop is being able to add a parent page. Even though, while writing this, i might have overlooked something.

    And yes indeed.. i was kind of looking forward to writing something myself. For it would be a nice puzzle:

    Would i then create a new page-{slug}.php and put all coding there? Preferably i would like to have the query/ function neatly embedded in the wp file system. And subsequently call the function via a shortcode..

    That way basically i can keep using the default templates..

    Kind regards..

    Dennis

    What i’m missing in the query loop is being able to add a parent page. Even though, while writing this, i might have overlooked something.

    It’s not that obvious, but it’s there.

    Click the + next to FILTER and select PARENT. This will enable the PARENT filter. Begin typing the title of the parent page into the PARENT filter box, and the page will appear for you to select it.

    Would i then create a new page-{slug}.php and put all coding there? Preferably i would like to have the query/ function neatly embedded in the wp file system. And subsequently call the function via a shortcode..

    The last sentence is not necessary at all: there’s no need to create any shortcode function to use your custom template.

    If you create the template file named page-{slug}.php… you simply have to create a PAGE with the same slug used in the file name, and this page will automagically use the custom template you created, loading all the content + code in that template file.

    For eg, if you created the template file page-community.php, you’ll create a PAGE with the slug community

    … and the permalink https://example.com/community/ will automatically use the custom template you created.

    The page can be completely blank (loading all its content from the template), or you could add additional content in the editor.

    See the documentation pages below on creating custom template files and the WordPress template hierarchy, which determines the template file WordPress uses to display content in different contexts.

    Note that you could also create a generic template if you want to reuse this across multiple pages and even posts. Even here, you don’t need to create/use any shortcode: in the editor, you can select the desired custom template to use for individual posts/pages if these custom templates exist.

    https://developer.wordpress.org/themes/basics/template-hierarchy/

    https://developer.wordpress.org/themes/template-files-section/page-template-files/

    • This reply was modified 1 week, 2 days ago by George Appiah. Reason: Fixed formatting

    Just want to add one cautionary note:

    If you create your custom page template in your original theme folder or edit any of your original theme files, you’ll lose these changes when you update the theme — as the entire theme folder is replaced during a theme update.

    The solution to this is to make all code changes (including creating additional template files) in a child theme.

    CSS changes can be added in APPEARANCE => CUSTOMIZE ADDITIONAL CSS. CSS code added here is saved in the database and remains in place when you update the theme.

    Thread Starter destmedia

    (@destmedia)

    Thanks again for your clear response. Do know things now that i didn`t know before.</p> <p class=””>For seo reasons i turned wp into my native language, which sometimes makes for ambiguous translations.. </p> <p class=””>On the last note.. What if i would like to write a function by myself similar to the query loop.. And don`t want to bloat my functions.php.. Where would i store it? And would wp pick up on it by itself or do i need to mount it somewhere?

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