Show Multiple Post Thumbnails only in one page - wordpress

I use Multiple Post Thumbnails plugin to add many thumbnails to my page.
for($i=1; $i<=10;$i++){
new MultiPostThumbnails(
array(
'label' => 'Photo - '.$i,
'id' => 'Photo-'.$i,
'post_type' => 'page'
)
);
}
But I need to have them only in one of the pages, not all. Now if I open any pages in admin, I see 10 Post Thumbnails fields. I need to specify the ID on the page and see them only in that page in admin.

Related

Code star framework add metabox to a specific page

I am using the code star framework full version. I have integrated the framework with the theme. How can I show the meta box option only for some specific pages ( like home page and about page )? Currently, the meta box options are showing all pages.
While creating metabox, you should pass "page_templates" value in array. For example, if you want to show metabox on homepage you should do:
$homePage = 'home-page';
CSF::createMetabox($homePage, array(
'title' => 'Homepage',
'post_type' => 'page',
'page_templates' => 'index.php', //filename goes here
'data_type' => 'serialize',
));
For more info: http://codestarframework.com/documentation/#/configurations?id=metabox-option-framework

Show Child post of Specific Parent on any page in Wordpress

I want to be able to use a shortcode to list a child post for a specfic parent on any page (custom post types mainly).
I found this: Show Child-pages of Specific Parent on any page in Wordpress
and it's perfect, but only for "pages" I think, it is not working for me with Custom Post Types.
Guillem,
You can keep use the code from this link.
Just add your custom post types in wp_list_pages function.
So, you will have:
$childpages = wp_list_pages( array(
'child_of' => $post->ID,
'title_li' => '',
'post_type' => 'YOUR_CPT_SLUG',
'echo' => 0,
) );

Dynamically maintain virtual pages URL without create pages from admin

I created a page named UserName its URL is http://my_site/username/. On this page I am showing three links, and each link behaves as meta info for UserName.
Let's suppose:
If UserName contains info about User then the three links are:
About Me
Images
Videos
and links contains href like:
http://my_site/username/about_me
http://my_site/username/images
http://my_site/username/videos
now I create three general files like:
about_me.php
images.php
videos.php
and want to include these file by checking the URL, but I don't know how.
I did it without adding new page from wp-admin because there will be so many UserName pages but they all have same three links and will show the info about respective user.
And if I prefer to create About Me child page whose parent will be the UserName page then admin will need to create 3*(n UserName) pages where n least value is 100 and could be 1000s
But when I click any link WP says
Page Not Found
This is somewhat embarrassing, isn’t it?
I select Custom Structure from Settings and I have no more idea about WP permalinks.
You may call I need to create Virtual pages for all users.
If it is not possible then is it possible that while adding new UserName page then on published three pages (About Me, Images & Videos) will automatically with parent page newly UserName page and with a defined Page Template. If it is possible then how?
Wow I got an idea, implement & hurray it worked.
In wp-admin/includes/post.php I add my script in function edit_post( $post_data = null )
First I checked if post not already exists then run my script which is:
$post = array(
'comment_status' => 'closed',
'ping_status' => 'closed',
'post_author' => $current_user_id,
'post_date' => date('Y-m-d H:i:s'),
'post_date_gmt' => date('Y-m-d H:i:s'),
'post_name' => 'Image',
'post_parent' => $post_parent,
'post_status' => 'publish',
'post_title' => 'Image',
'post_type' => 'page'
);
// Insert in to WP wp_posts table
$this_post_id = wp_insert_post( $post, $wp_error );
// Insert in to wp_postmeta table
$meta_id = update_post_meta($this_post_id , '_wp_page_template', 'page-three-columns.php');

Wordpress - adding custom post type category to menu

I have a custom post type named 'The Books', and a relative category named 'The Books' for these custom posts.
When I add the category The Posts to my nav menu, it doesn't work because it goes to the URL /category/the-books instead of just going to /the-books. If I posted this in the default post section it shows correctly, but when I post in the custom post section it does not return my post. I can, of course, add individual posts from my custom post section to the nav menu, but can't figure out how to add an archive page of the custom posts.
My permalinks are set to: URL/%postname%/ so I'm not sure why that is happening.
Here's the function for my custom posts:
add_action( 'init', 'create_post_type' );
function create_post_type() {
register_post_type( 'hpl_books',
array(
'labels' => array(
'name' => __( 'The Books' ),
'singular_name' => __( 'Book' )
),
'taxonomies' => array('category'),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'the-books'),
)
);
}
Any advice is greatly appreciated.
thanks!
You shouldn't need to add a category "the-books" in order to display the results.
Have you created a view in your page-templates directory called "archive-hpl_books.php?" That's the file WordPress will look for to display the archive of your custom post type. Basically, you would create a page called "the-books" or whatever, then set archive-hpl_books.php as the template.
See http://codex.wordpress.org/Template_Hierarchy
I'm only responding to this because I just went through a similar issue, so I'm down to help out. :)

Multiple Featured Images Wordpress

So my aim is to find a method of adding more thumbnails only for displaying on a custom post type, for example I wish to have a large image (not the same image) for a featured post and a different image for the default view.
In the end i followed this tutorial and it did exactly what i required to a T.
http://www.lifeonlars.com/wordpress/how-to-add-multiple-featured-images-in-wordpress
have you try this add_image_size
why don't you use custom post template plugin
I got a solution from online. I also customized some code. You can check this.
Step 1 Download this library from this link and put beside functions.php ( theme root ).
Step 2: Copy this code below to functions.php.
/*
* Code for Multiple Featured Image.
* Multiple Featured image is only for your selected post type.
*/
require_once('library/multi-post-thumbnails.php');
if (class_exists('MultiPostThumbnails')) {
new MultiPostThumbnails(array(
'label' => '2nd Feature Image',
'id' => 'feature-image-2',
'post_type' => 'your_post_type_name'
)
);
new MultiPostThumbnails(array(
'label' => '3rd Feature Image',
'id' => 'feature-image-3',
'post_type' => 'your_post_type_name'
)
);
new MultiPostThumbnails(array(
'label' => '4th Feature Image',
'id' => 'feature-image-4',
'post_type' => 'your_post_type_name'
)
);
};
Step 3 Check now.
I can write entire code here, but clicking on this tutorial link is much easier :)

Resources