Skip Navigation

[Résolu] Structure of related pages

This support ticket is created Il y a 7 années et 10 mois. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+01:00)

This topic contains 38 réponses, has 2 voix.

Last updated by AndreG3332 Il y a 7 années et 9 mois.

Assisted by: Nigel.

Auteur
Publications
#406023

HI Guys,

I need a bit of guidance as to how too approach a design issue.

Back ground: This is for a bit of advanced blog site. The basics of the site is the blogger will write articles for various clients (partners) and the partners are linked to each article via parent (partner) and blog(child) relationship. There will be various categories and this will be added to as new partners sign up for the service. The required specks i am sitting with :
On the home page the categories must be listed and dynamically updated This I got done with a view.
hidden link under the heading "articles".

This is now where i am black how to further. The image and the heading must be hyper linked that when you click on a category ie general, the general category must open with a list of all partners that have articles listed under that category. Then when you click on the partner name a excerpt blog post page must open where all the blogs linked with that partner must show as excerpts with read more functions that will then open the article in full when clicked on read more tag.

My questions at this stage is:
Once the home page categories are loaded as done on the link above, and clicked do I hyperlink to a view , a template or a page with a short code on, to open "that" category with a list of partners on?

and then the same question once i click on a partner where do I hyperlink that to, to show me a list of blogs for that partner. The final bit is ok because I know that I can do as simple template to show the full article.

#406056

Nigel
Supporter

Languages: Anglais (English ) Espagnol (Español )

Timezone: Europe/London (GMT+01:00)

A new version of Views is imminent (got held up in QA testing this week, we are still hopeful it will be released next week) which is going to give you more options and make what you want to achieve easier.

Starting with your set up whereby you have hierarchical CPTs like so: Partners > Articles.

My first suggestion would be to go with core WordPress functionality unless there is a good reason not to. Rather than creating a CPT for the partners, can you use WordPress users and assign the users as authors of the articles? Is there a reason why you cannot? You can create custom user fields to personalise the author profiles.

Just be sure when creating/editing your Articles custom post type under "Sections to display" that author is checked so that when you are editing your articles the dropdown to select the author is visible.

The next release of Views brings with it parametric searches on archive pages. That means, rather than the 3-step process you describe to see articles, you can have an articles archive page with filters at the top so that the users can change categories and change post authors (partners) and have the results update to show the article excerpts with links, all without leaving the page.

That would be my recommended solution. Documentation is already available here:
https://toolset.com/documentation/user-guides/adding-parametric-search-wordpress-archives/

If you wanted to persist with your 3-step solution, you would create a category View to display the categories, and in the loop output section you can add the taxonomy title as a link to the individual category archives. You'll have to add this View to a page where the users start the article search.

You would then need to make a custom category archive at Toolset > WordPress archives. This normally displays a list of posts within the category. You will need to output the author name with a link to their author archive instead. The problem is that the author will be duplicated for every post they have in that category. In the current version of Views you would need custom code using the Views PHP filters (https://toolset.com/documentation/user-guides/views-filters/) to limit this to a single result for each author, but the upcoming versions of Views will enable you to do this without writing any PHP.

So, hopefully you can wait a few days for the new version before building your solution...

#406067

HI Nigel,

Thx for your prompt response. You have given me some food for thought and i need to look into your suggestions. There are already one or two questions I have but i just want to work through it all and take a look and the upgrade where after i will harass you further.

Fortunately i am in a position to hang around for the new software to be released.

#406083

Nigel
Supporter

Languages: Anglais (English ) Espagnol (Español )

Timezone: Europe/London (GMT+01:00)

Hi Andre

Thanks for your patience, let me know if you have any follow-up questions.

-Nigel

#407839

HI Nigel,

i got the upgrade and very nice! There are a point or two that we had a bit of misunderstanding on however your reply did guide me enough to find a solution or two. My next question relates to the following.

I do apologize if my questions are bit simple but i am in a very steep learning and curve and it is mostly very simple things that trip me up at the moment.

( and i can comment your support teams has been super helpfull!)
Here is my issue.
hidden link
if you scroll down to the area articles you will see the result of a view of taxonomy "category".

Now when i click on either the image or the text bit i need it to open this post.
hidden link that is linked to the category optioned clicked.

This is the result of a wordpress taxonomy called Partners.

Each partner cpt does have a category linked to that partner that is represented in the first link.
What i need now is that when you click on the category image or text is that the partners template is opened up but it must only show the partners linked to that
taxonomy.

My problem is the construct of that <a> tag.

#407919

Nigel
Supporter

Languages: Anglais (English ) Espagnol (Español )

Timezone: Europe/London (GMT+01:00)

Can I clarify a few details before I propose a solution?

You have a Partner custom post type which is parent to the Article custom post type (which are your blog articles).

You have Categories as your taxonomy. These are assigned to the partner, the article, or both?

On the home page you list your categories. When a user clicks a category you want them to go to a page which shows the partners who have published articles for that category, but not the articles themselves. When the user clicks a partner they are taken to another page where they see the articles published by that partner in the category chosen in the initial step.

Does that sound right?

#407968

Your summary is spot on! The categories are only link to the articles (Blog). The reason behind that is that a article may relate to multiple categories. It creates a problem if categories are also linked to the partners as the may be a different set of categories to related articles. Hope that make sense. The result thus would be a many to many relationship between partners and categories via Posts.

The only difference is that I opted to rather use posts (default wordpress post type) that articles (cpt) and the categories are set as taxonomy to post

Somebody suggested always rather use build in functions where possible however I am not against the option of using the article cpt instead of the built in post if it is a better way of achieving my goal.

#408203

Nigel
Supporter

Languages: Anglais (English ) Espagnol (Español )

Timezone: Europe/London (GMT+01:00)

View from step 3.png
View from step 2.png

OK, so I had it right except there is no article custom post type, you just use normal WordPress posts for the articles, yes?

This would be pretty straightforward with a parametric search as described in my first response, but the multi-step solution is rather convoluted, hopefully you can follow along.

On your home page you need

- 1. a view that lists the categories with links to...

- 2. a page that shows the parent partners that have published posts with that category, which link to...

- 3. the list of posts by that partner in that category

Here's how I did that on a test site:

1. First I created a page where I will show partners for step 2 that I will link to from here and note the post id, which in my case is 88. Then I created a taxonomy view that displays categories. I need to link to the partners page and pass the category selected as a url parameter 'wpvcategory', so my somewhat crude loop output looks like:

	<wpv-loop>
		<p><a href="[wpv-post-url id='88']?wpvcategory=[wpv-taxonomy-slug]">[wpv-taxonomy-title]</a></p>
	</wpv-loop>

You can add this view to your homepage and it will display the categories with the necessary links.

2. On my partners page I need to add a new posts view which will display partners. No filters because we will loop through all all partners even though we only want to show partners who have written posts in the chosen category.

The trick here is that we won't output anything directly in this view, which serves as a container for a nested view we will create next. We haven't made that view yet, but in my example I call it 'Posts of a partner', and my container view for this outer loop will end up looking like this:

	<wpv-loop>
		[wpv-view name="posts-of-a-partner"]
	</wpv-loop>

Now to create that nested view Posts of a partner. This is where we will actually output a list of the partners, with a link to the individual partner pages that will be used in step 3 to display the actual posts (belonging to the partner and the chosen category).

But the categories are assigned to the posts, not to the partners, and so this view will be a posts view that returns posts (not partners), but in the loop output we will generate our partner names and links by referring to the parent of the post using the id attribute so that, although we are querying posts, we will output partners.

We need to add a filter for the category that was passed in the url parameter wpvcategory, and another filter referring back to the partner specified in our outer loop from the containing view.

One more complication is that we don't want the partners repeating for every qualifying post, so we limit this query to just 1 result which effectively gives us a binary partner-does or partner-does-not have posts in this category.

See the screenshot for how this looks when set up.

And here's the loop output that shows the partner name and links to the partner single post page where we are going to display our qualifying posts in the next step.

	<wpv-loop>
		<p><a href="[wpv-post-url id="$partner"]?wpvcategory=[wpv-post-taxonomy type='category' format='slug']">[wpv-post-title id="$partner"]</a></p>
	</wpv-loop>

3. I have chosen to display the qualifying posts on the single partner post page so that tells us which partner we are looking at, otherwise with a different page we would have to pass the partner information as a url parameter, too. So I will use a Content Template for partner single posts and add the View I'm about to create to that template.

So I make a new view which is very similar to the last step, which displays posts filtered by category (passed by url parameter) and by partner (determined by the page we are on).

No limit this time because we want all the posts.

In my test site I'm just outputting a the post title as a link.

#408280

Hi Nigel Thx for the very comprehensive reply. I have started working through the solution. If it is ok with you I would like to ask questions I go along. My first question.

With the partner setup would it be preferable to do it as a page of would it be ok to do it as a WordPress archive, as i have done, direct ie not a physical page? And why? I am trying to really understand the ins and outs so that I don't have to ask a similar question in the future for something similar.

#408416

Nigel
Supporter

Languages: Anglais (English ) Espagnol (Español )

Timezone: Europe/London (GMT+01:00)

That would work, too, you can use the partners WordPress archive which will return all partners and for the loop output use the embedded View posts-of-a-partner.

You will just need to adjust the link slightly so that you go to the partner archive rather than the page id I suggested.

#408865

HI Nigel,

I have tried your link and changed to the archive but i am still getting a 404 error, Here is my code

<div class="cat-image">
[types termmeta="category-image"][/types]<br>
  </div>
<div class="cat-heading">  
  <a href="[wpv-archive-link name="partner"]?wpvcategory=[wpv-taxonomy-slug]"><h3>[wpv-taxonomy-title]</h3></a>
</div>

This used in the Loop item in Categories table view Home page view that should link met to this archive post.

hidden link

any idea where i am getting it wrong?

#408976

Nigel
Supporter

Languages: Anglais (English ) Espagnol (Español )

Timezone: Europe/London (GMT+01:00)

I think it is simply a quotes problem.

Try replacing the quotes around partner with single quotes to differentiate them from the double quotes used for your link href.

#409339

Hi Nigel,

Thx your solution was spot on! Such a stupid mistake. My next question is now relating to the following bit in your original answer. Point two in your reply #408203. There you suggested I make an inner loop posts-of-a-partner and then create a outer loop view that references the inner loop.
However subsequent conversation changed from a view to a wordpress archive (WA) that I was able to reference to step1 in in the process and this is working. However there is now something wierd going on. When i click on the category to open the WA the result is inconsistent with the expected result. There are currently two partners loaded on the system 1 Naturaly bronwyn, and 2 purplehashtag. When i click in a category "parenting" that should should show "1" it shows "2" instead.

The code for the loop editor output for the WordPress Archive is

[wpv-layout-start]
	[wpv-items-found]
	<!-- wpv-loop-start -->
	<table width="100%" class="wpv-loop js-wpv-loop">
	<wpv-loop wrap="2" pad="true">
		[wpv-item index=1]
		<tr>
			<td>
				[wpv-post-body view_template="Loop item in Partners"]
			</td>
		[wpv-item index=other]
			<td>
				[wpv-post-body view_template="Loop item in Partners"]
			</td>
		[wpv-item index=2]
			<td>
				[wpv-post-body view_template="Loop item in Partners"]
			</td>
		</tr>
		[wpv-item index=pad]
			<td></td>
		[wpv-item index=pad-last]
			<td></td>
		</tr>
	</wpv-loop>
	</table>
	<!-- wpv-loop-end -->
	[/wpv-items-found]
	[wpv-no-items-found]
		<strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong>
	[/wpv-no-items-found]
[wpv-layout-end]

While the template editor is

[wpv-view name="Posts of a Partner"]

The view for Loop Output Editor "Posts of a Partner" code is

[wpv-layout-start]
	[wpv-items-found]
	<!-- wpv-loop-start -->
	<wpv-loop>
		[wpv-post-body view_template="Loop item in Posts of a Partner"]
	</wpv-loop>
	<!-- wpv-loop-end -->
	[/wpv-items-found]
	[wpv-no-items-found]
		<strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong>
	[/wpv-no-items-found]
[wpv-layout-end]

and the template is

[types field='logo' size='medium' align='left' resize='proportional'][/types]
[types field='company-name'][/types]
[types field='website'][/types]

#409580

Nigel
Supporter

Languages: Anglais (English ) Espagnol (Español )

Timezone: Europe/London (GMT+01:00)

I have a series of posts scattered between 4 partners and 3 categories, and on my category view I added links to both the partner WordPress archive and the partners page from my original solution and in testing there was no difference between the two and both showed the correct partners when first selecting a category and the correct posts when then selecting the partner.

Which is to say that it should work and not matter whether you are using the WordPress archive or a standalone page for the partners.

Looking at your code samples, for your partners WordPress archive you are not inserting the View, no?

Here's the relevant part of my archive loop output:

<!-- wpv-loop-start -->
<wpv-loop>
    [wpv-view name="posts-of-a-partner"]
</wpv-loop>
<!-- wpv-loop-end -->

I've added my inner View, you have added a Content Template.

That inner View then displays posts filtered by category (passed via url parameter) and by parent, as shown in the screenshot in #408203 above.

If you set up your Views the same as I have hopefully you'll get the same result.

#409692

Hi Nigel,

I think i might have explained it a bit bad.

As far as i can see i have done as you have suggested. the [wpv-view name="posts-of-a-partner"] is as part of my archive. It is just in the template section fo the wordpress archive. Because i used a table layout toolset created a template "Loop item in Partners" and the above code is in that template as it is being used more that once because of the table layout.

The issue that i have and this is my problem; when i click on the parenting category on the home page it does not open the partner that is linked to a post that has this category allocated to it. It opens up the only partner that does not have a post linked to it so there are no relationship between the partner that is show and the category that is selected.

It may help if you can log in to the account. it is a development site so there are no issues with you looking at it. may be easier to understand the problem.

If I can summerise:

There are two partners loaded on the system. naturaly bronwyn and purplehashtag. The posts that are there are all linked to NB. and the one category that are used is parenting.

When i click on the parenting category the partner archive is opened but instead of NB showing Purplehashtag is showing.

If you can send me the private section i can supply you with the login details.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.