Support » Plugin: Posts 2 Posts » [Plugin: Posts 2 Posts] Display metabox only for specific post ID or specific teplate

Viewing 15 replies - 1 through 15 (of 31 total)
  • Plugin Author scribu

    (@scribu)

    The main difficulty is this: the P2P metaboxes also show up when creating a new post. You can’t check these kinds of conditions until after the post is created.

    Thread Starter Amit

    (@obvio)

    Hi, thanks for the fast response.

    This is ‘not that of a concern’ (ie. I can live with that) because usually pages will be preset for the user, or in case not, a user-manual can always include ‘use X page template, save your page to enable all boxes.. and continue editing’, at least that’s the case with WPAlchemy (linked above).

    Thanks again!

    Plugin Author scribu

    (@scribu)

    I won’t be adding any parameters for this, but I did introduce a new filter, present in the development version (1.3-alpha2).

    Example usage:

    function restrict_p2p_box_display( $show, $post, $ctype ) {
    	if ( 'YOUR_CONNECTION_TYPE' == $ctype->name ) {
    		return ( 'YOUR-TEMPLATE.php' == $post->page_template );
    	}
    
    	return $show;
    }
    
    add_filter( 'p2p_admin_box_show', 'restrict_p2p_box_display', 10, 3 );
    Thread Starter Amit

    (@obvio)

    Amazing! works great!
    thanks!

    Plugin Author scribu

    (@scribu)

    In the development version (1.3.1-alpha), I changed the parameter order, to be consistent with the other filters. When you update, you’ll have to replace this:

    function restrict_p2p_box_display( $show, $post, $ctype ) {

    with:

    function restrict_p2p_box_display( $show, $ctype, $post ) {

    Sorry for the inconvenience.

    Hi scribu,

    What if you only want to display the Admin Box for a certain connection type on one specific page? How would I do that? Let’s say I want to connect a post from a certain post-type only from page with ID = 14.

    My code does work, the box only shows up on the specific page, but when I try to connect a post, it doesn’t find any…

    [Code moderated as per the Forum Rules. The maximum number of lines of code that you can post in these forums is ten lines. Please use the pastebin]

    Am I doing something wrong, or is it not possible yet with this function?
    Many thanks as always!

    Plugin Author scribu

    (@scribu)

    Your code got moderated.

    Sorry about that…
    Here’s my code in pastebin
    Thanks!

    Plugin Author scribu

    (@scribu)

    This should be fixed in the development version (1.4-alpha).

    More info: https://github.com/scribu/wp-posts-to-posts/issues/175

    Yes, fixed! 🙂 Brilliant!
    One thing I noticed though in this alpha version, is that in all the Admin boxes underneath the ‘search’ tab, all the posts are shown with navigation arrows. I believe those were only visible when you searched for something in the previous versions?
    Thanks for your swift action!

    Plugin Author scribu

    (@scribu)

    Screenshot please.

    There you go:
    http://imageshack.us/f/801/schermafbeelding2012060.png/

    As you can see, below the search type fields, all the possible connections are allready visible. The Admin Boxes use a lot more space like this. I think this wasn’t like that in previous versions?

    Thanks!

    Plugin Author scribu

    (@scribu)

    Oh, yeah, that’s an intentional change. If you want to make a case against it, please comment here:

    https://github.com/scribu/wp-posts-to-posts/issues/170

    Ah okay, was wundering about that… No need to make a case against it 🙂
    Thanks!

    Hi scribu,
    The above code doesn’t work anymore after updating from the development 1.4-alpha to the 1.4 version… The connection box on that page only is still there and the connections too, but it doesn’t show any connected posts anymore on the frontend.
    Any ideas? Thanks!

Viewing 15 replies - 1 through 15 (of 31 total)
  • The topic ‘[Plugin: Posts 2 Posts] Display metabox only for specific post ID or specific teplate’ is closed to new replies.