Quantcast
Channel: How to include an RSS feed or search results on a single template? | WordPress.org
Viewing all articles
Browse latest Browse all 8

Simon Wheatley on "How to include an RSS feed or search results on a single template?"

$
0
0

Hi there,

You are trying to use the_title to return the string value for the post title, You need get_the_title instead.

However, you have some fundamental issues with the efficiency and structure of your approach to the problem. I suggest:

You should use a “Restaurant” Custom Post Type for your restaurants. This will keep the descriptions separated from the news information. Currently you are in danger of having the restaurant description returned as part of the news, meaning the same information would be shown twice. You can google any number of different tutorials on adding a custom post type to your site.

Assuming the news is in the same site as the descriptions, the approach of fetching the feed for the search for the restaurant is not necessary and inefficient. Instead you should use a WP_Query (http://codex.wordpress.org/Class_Reference/WP_Query - looking at "Usage" and "Search Parameter"). Alternatively, you might use a new "Restaurant" Taxonomy to indicate which restaurant Wah piece if news relates to (you could then use the taxonomy parameters in WP_Query to return just news relating to that restaurant). You might also use our Sync Post Types to Taxonomies plugin (https://github.com/cftp/sync-post-types-to-taxonomies) to ensure that for each restaurant post in your custom post type, there was an auto-created term in the restaurant taxonomy to tag news posts with.

I hope this helps.

Simon


Viewing all articles
Browse latest Browse all 8

Trending Articles