{"id":3435,"date":"2018-11-06T02:23:56","date_gmt":"2018-11-06T02:23:56","guid":{"rendered":"https:\/\/docs.contentviewspro.com\/?p=3435"},"modified":"2023-12-28T08:17:24","modified_gmt":"2023-12-28T08:17:24","password":"","slug":"show-posts-list-of-custom-code-or-another-plugin-in-content-views-pro-layout","status":"publish","type":"docs","link":"https:\/\/contentviewspro.com\/documentation\/article\/show-posts-list-of-custom-code-or-another-plugin-in-content-views-pro-layout\/","title":{"rendered":"Show results of custom code, api, another plugin"},"content":{"rendered":"<p>In case you used custom code to query posts, or used another plugin to get posts, you can use Content Views Pro to display these posts in a beautiful grid or list.<br \/>\nHere is the code you need to use:<\/p>\n<pre style=\"font-size:13px\">\n$pids = array();\n\n\/\/ #1: If there is existing variable contains array of post objects\n\/\/ Replace $posts by the existing variable\nif ( isset( $posts ) ) {\n\tforeach ( $posts as $post ) {\n\t\t$pids[] = $post->ID;\n\t}\n} \nelse {\n\t\/\/ #2: If there is existing loop\n\t\/\/ Replace null by the query variable\n\t$query_obj = null;\n\twhile ( $query_obj ? $query_obj->have_posts() : have_posts() ) :\n\t\t$query_obj ? $query_obj->the_post() : the_post();\n\t\t$pids[] = get_the_ID();\n\tendwhile;\n}\n\n\/\/ Replace VIEW_ID with the ID string of your grid\/list View\necho do_shortcode('&#91;pt_view id=\"VIEW_ID\" post_type=\"any\" post_id=\"' . implode( ',', $pids ) . '\"&#93;');\n<\/pre>\n<blockquote><p>Notice: Above code requires your knowledge of PHP.<br \/>\nAlso, the view should NOT enable Live Filter or any kind of other filters, it should use default Filter Settings.<\/p><\/blockquote>\n<p>Best regards,<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In case you used custom code to query posts, or used another plugin to get posts, you can use Content Views Pro to display these posts in a beautiful grid or list. Here is the code you need to use: $pids = array(); \/\/ #1: If there is existing variable contains array of post objects &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"\" href=\"https:\/\/contentviewspro.com\/documentation\/article\/show-posts-list-of-custom-code-or-another-plugin-in-content-views-pro-layout\/\"> <span class=\"screen-reader-text\">Show results of custom code, api, another plugin<\/span> Read More &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"site-sidebar-layout":"default","site-content-layout":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","footnotes":""},"doc_category":[14],"doc_tag":[21],"class_list":["post-3435","docs","type-docs","status-publish","hentry","doc_category-plugins","doc_tag-custom-code"],"year_month":"2026-09","word_count":168,"total_views":"0","reactions":{"happy":"1","normal":"0","sad":"0"},"author_info":{"name":"admin1","author_nicename":"admin1","author_url":"https:\/\/contentviewspro.com\/documentation\/author\/admin1\/"},"doc_category_info":[{"term_name":"Work with Themes &amp; Plugins","term_url":"https:\/\/contentviewspro.com\/documentation\/cats\/plugins\/"}],"doc_tag_info":[{"term_name":"custom PHP code","term_url":"https:\/\/contentviewspro.com\/documentation\/tags\/custom-code\/"}],"_links":{"self":[{"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/docs\/3435","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/comments?post=3435"}],"version-history":[{"count":6,"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/docs\/3435\/revisions"}],"predecessor-version":[{"id":5481,"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/docs\/3435\/revisions\/5481"}],"wp:attachment":[{"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/media?parent=3435"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/doc_category?post=3435"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/doc_tag?post=3435"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}