Skip Navigation

[Resolved] Include Child Posts in Search Results

The Toolset Community Forum is closed, for technical support questions, please head on to our Toolset Professional Support (for paid clients), with any pre-sale or admin question please contact us here.
This support ticket is created 9 years, 2 months ago. There's a good chance that you are reading advice that it now obsolete.
This is the community support forum for Types plugin, which is part of Toolset. Toolset is a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 4 replies, has 2 voices.

Last updated by Caridad 9 years, 1 month ago.

Assisted by: Minesh.

Author
Posts
#277299

I am trying to: Use the WordPress search form to search for an artist/band name and get all information on the site about that particular artist/band. For example, I have Artists that is a Parent post type to Albums. When I type an artist's name into the search field I want to get results with the artist's page as well as all albums associated with them.

I visited this URL: hidden link <- the search is for an artist

I expected to see: Search results with the artist's page, as well as any albums associated with the artist. In this particular case there is one album linked to this artist, so there should be two results in the search page.

Instead, I got: Just the artist's page. No album was listed.

I do have the album associated correctly with the artist as you can see in this screenshot: hidden link

I found that the search results do display albums as desired sometimes, but only if the artist's name also happens to be in the album description. However this is not the case all the time.

#277509

WordPress search works on post by post basis. Its searching in the title and content of the parent post and also in the child post and It will display only the posts where this text is found.

You will need some degree of custom code to get exactly what you want or adapt your requirements.

Let me know if you have any questions.
Regards
Caridad

#277834

I understand what you're saying, but it seems like the search should still work based on what I have.

For example, the search for the artist name "The Mint Chicks" here hidden link should result in the artist's bio page (it does), as well as the one album, which is linked to that artist (albums are child posts of the artist).

However the search results do not display the album, although the album does include the artist's name in the content (see here: hidden link). The artist's name in the content gets fed from the parent posts' title like this:

[wpv-post-title id="$artists"]

On other albums where the artist's name is used in the

[types field="album-description"][/types]

, or

[types field="track-listing"][/types]

, the album does show up in the search results when searching for the artist's (parent) name.

I don't know if this will help or not, but the full album content template code is:

<div class="album-container">
  <div class="album-left">
	  <div class="album-thumb">
		<img src='[types field="main-cover-image" size="medium" url="true" resize="crop"][/types]' itemprop="image" /><br />
      </div>
		<div class="buy-links">
		[wpv-if amazon="wpcf-amazon-link" evaluate="!empty($amazon)"]
			<a href='[types field="amazon-link" output="raw"][/types]'>
			  <img src="/wp-content/uploads/2014/12/amazon.jpg" width="70px" height="14px" alt="Buy [wpv-post-title] on Amazon" />
			</a>
		[/wpv-if]
		[wpv-if itunes="wpcf-itunes-link" evaluate="!empty($itunes)"]
			<a href='[types field="itunes-link" output="raw"][/types]'>
			  <img src="/wp-content/uploads/2014/12/itunes.jpg" width="70px" height="26px" alt="Buy [wpv-post-title] on iTunes" />
			</a>
		[/wpv-if]
		[wpv-if store="wpcf-store-link" evaluate="!empty($store)"]
			<a href='[types field="store-link" output="raw"][/types]'>
			  <img src="/wp-content/uploads/2014/12/-Logo-Small.jpg" width="70px" height="29px" alt="Buy [wpv-post-title] on  Records Store" />
			</a>
		[/wpv-if]
		</div>
	  <div class="album-tracks">
		<h3>Tracks on [wpv-post-title]</h3>
		<ol itemprop="track" itemscope itemtype="<em><u>hidden link</u></em>"><span itemprop="numberOfItems" content=[count-tracks field="track-listing"] />
		  <li itemprop='itemListElement' itemscope itemtype='<em><u>hidden link</u></em> itemprop='item' itemscope itemtype='<em><u>hidden link</u></em> itemprop='name'>[types field="track-listing" separator="</li></span></span><li itemprop='itemListElement' itemscope itemtype='<em><u>hidden link</u></em> itemprop='item' itemscope itemtype='<em><u>hidden link</u></em> itemprop='name'>"][/types]</span></span></li>
		</ol>
	  </div>
  </div>
  <div class="album-content">
    <strong><span itemprop="name">[wpv-post-title]</span> by <span itemprop="byArtist">[wpv-post-title id="$artists"]</span></strong><br />
    [types field="album-description"][/types]<br />
    
  </div>
</div>

Perhaps the answer is as simple as just making sure that the artist's name is in the album content somewhere, but there are several hundred albums, so I was hoping for an easier solution.

#278871

Let me ask the development team for ideas and I will get back to you.

Regards
Caridad

#279883

You can create a View for searching instead of using WordPress search engine.

In this View you can select where you want to search (Artists) and you have the chance to customize the display of found artists.

Here in the View Layout is where you can insert a child View for listing albums. In the albums child view you need a filter for the relationship to match the post in the parent View.

This means that searching for "Artist One" produces the following output:

Artist One
- Album 1
- Album 2

Please let me know if you are satisfied with my reply and any other questions you may have.

Regards,
Caridad

The forum ‘Types Community Support’ is closed to new topics and replies.

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