0

I am working on a plugin which creates a custom post type. The custom post type generates a google map, and plots the location specified in the post of the CPT on to a google map.

I'd like to remove this CPT from displaying the_content(); and the_title(); etc. in the regular loop.

Since the post type I've created has the ability for the user to click the pin on the map to display the_content(); there is no need to have this information displayed in regular text format on the page, like a regular post type would look.

Is there a solution that will eliminate this post type from the loop on the page templates of any theme that I can use in my plugin code?

Edit: I have constructed a shortcode, that can display the CPT map on any page. Inside the shortcode it loops through each post of the CPT to get its location and plot it on the map.

What is happening is, if I insert the short code on any given page, the map works great, but the page is also displaying the title and content of the CPT underneath the map as well. It appears that this is because the page I've posted the short code on is grabbing the loop from within the short code and applying it to the page template of page. This is duplicating content, it is displayed once on the map, and once in the loop of the page template.

1
  • 1
    Please show us the underlying function of the shortcode. I guess you just didn't reset the postdata.
    – tfrommen
    Feb 2 '14 at 17:29
0

I'm afraid I don't get the problem. The Loop usually only queries and displays post posts, and no custom posts. If your theme also lists your CPT, then you have to have a look at the query arguments.

Apart from that: When you register_post_type, you have several options to choose from and set.

I would say, you would use the following:

'public' => true,
'exclude_from_search' => true,
'publicly_queryable' => false,

Now your CPT only shows up if it is explicitly queried (as you would do on your Google Maps page, if I got you correctly).

2
  • 1
    Sorry. I should have been more clear.. I have constructed a shortcode, that can display the CPT map on any page. Inside the shortcode it loops through each post of the CPT to get its location and plot it on the map. What is happening is, if I insert the short code on any given page, the map works great, but the page is also displaying the title and content of the CPT underneath the map as well. It appears that this is because the page I've posted the short code on is grabbing the loop from within the short code and applying it to the page template of page. This is duplicating content.
    – user32829
    Feb 2 '14 at 17:21
  • Well, yeah. ;) But you can still do so. Just edit your question.
    – tfrommen
    Feb 2 '14 at 17:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy