Output of portfolio works in the form of a grid with a filter - lesson 27

Data is added and output, but I would like not just to display data, but to make something similar to a real portfolio, with a list of works that can be viewed and filtered. Right now, our portfolio looks like regular posts. You can see the work of the portfolio we created earlier by clicking on the link https://{your site}/my-portfolio/

How to display portfolio now

wordpress portfolio taxonomy

How will the portfolio be displayed after completion

worpress portfolio themplate example

Gallery demo on the developer's site

We continue to work on our theme

I think you, like me, don't like it very much, that the link looks like /my-portfolio/, let's change this in the file /wp-content/themes/my_theme_tmp/functions/custom-type.php.

wordpress portfolio slug

Let's change slug such my-portfolio on portfolio. If you follow your link https://{your site}/portfolio/, you may run into a problem, since we have already created a page with a label (slug) portfolio. In order for our records to be displayed well again, Let's delete the page labeled portfolio.

wordpress delete portfolio page

After deleting a page, wordpress still remembers it. To permanently close the issue with the portfolio label, we need to remove this page from the basket.

delete portfolio page from treshAfter these actions, the template of a separate page is no longer displayed for me, but i found a way. If you have the same error, then you need in the settings in the section “Permalinks” first switch to default view (Default), so that all links work in the form https://wp-admin.com.ua/?p=123, save the setting.

wordpress parmalink settings

After saving again in the link settings, select “Title records“, as shown below and save.

wordpress parmalink settings single

After these not tricky manipulations, links and a new label of an arbitrary type should work normally again. /portfolio/.

Customizing the output template

After setting up beautiful links, let's move on to setting up a template for displaying all works in the portfolio. We'll call the template archive-my_works.php (archive-{post type}.php). Since our type was called my_work, then the creation of a file with this name will be automatically assigned to the list of records of this type.

The name of our type can be seen in the file /wp-content/themes/my_theme_tmp/functions/custom-type.php, in the picture below i will show where to look.

wordpress custom type nameLet's place the base code of the top, central and lower.

Since the portfolio will use new scripts, then we will need to connect them. Scripts need to be connected like this, so that they are displayed between the tags <head></head>, but did not change the main template code header.php.

To connect scripts create a file /functions/ create file custom-header-script.php and plug it in functions.php our theme.

wordpress requery custom script

To file custom-header-script.php enter the code to connect the gallery script.

 

The above script connects CSS and JS files in WordPress to that place, where in the file header.php installed function wp_head(). You can read more about the functions of connecting fonts on my article “Working with jquery in WordPress“, which, using the jquery library as an example, shows how to include scripts. You can also read about including styles in the WordPress codex..

My example has a custom function uGetPostType() created by me, it serves to pull out the current data type on the current page. Based on the received type, we determine whether we need to add scripts to the site header or not.

The next step is to add a gallery to your website files.. Download the gallery archive below and put it in a folder /wp-content/themes/my_theme_tmp/js/simple-portfolio-page/… .

zip wordpress theme archive

I offer you my code for displaying this gallery in a file archive-my_works.php:

The code is quite large, but i added comments, to make it easier to understand. Below you can download the full code of the template at the moment.

zip wordpress theme archive

The last thing left for us is to add a link to the portfolio in the menu of our site. We go to the menu Appearance -> Menu -> Links and add a new link /portfolio/, put the resulting link in the right place.

add wordpress menu portfolio - Wordpress courses

Move the menu item to the right place, so that when you enter the site it can be seen.

Portfolio template ready to go, try to understand the lesson, If it does not work out, then ask questions in the comments. I'll try to answer them as soon as possible.

In the next tutorial, we will implement the opening of each job in a pop-up window. (lightbox) for portfolio.


Buy WordPress hosting
WordPress tutor
Online tutoring services. List of courses I teach
  • Basic web design course;
  • Site layout;
  • General course on CMS WordPress and continuation of the course on template development;
  • Website development in PHP.
Read more on the page WordPress tutor
*/

Nikolaenko Maxim

Director of web studies ProGrafika. I am developing, website design and promotion. Always glad to new blog readers and good clients.


You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Templates for WordPress
The best hosting in Ukraine
Stable hosting for Drupal