Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author Johan van der Wijk

    (@vanderwijk)

    HI Jonah, I would be happy to provide a filter for making the content_block post type public in specific cases. Could you provide a code suggestion for implementing this?

    Thread Starter jonahcoyote

    (@jonahcoyote)

    Hi Johan,

    Here you go:
    In /wp-content/plugins/custom-post-widget/post-widget.php:

    // Create the Content Block custom post type
    add_action( 'init', 'my_content_block_post_type_init' );
    
    function my_content_block_post_type_init() {
    	$labels = array(
    		'name' => _x( 'Content Blocks', 'post type general name', 'custom-post-widget' ),
    		'singular_name' => _x( 'Content Block', 'post type singular name', 'custom-post-widget' ),
    		'plural_name' => _x( 'Content Blocks', 'post type plural name', 'custom-post-widget' ),
    		'add_new' => _x( 'Add Content Block', 'block', 'custom-post-widget' ),
    		'add_new_item' => __( 'Add New Content Block', 'custom-post-widget' ),
    		'edit_item' => __( 'Edit Content Block', 'custom-post-widget' ),
    		'new_item' => __( 'New Content Block', 'custom-post-widget' ),
    		'view_item' => __( 'View Content Block', 'custom-post-widget' ),
    		'search_items' => __( 'Search Content Blocks', 'custom-post-widget' ),
    		'not_found' =>  __( 'No Content Blocks Found', 'custom-post-widget' ),
    		'not_found_in_trash' => __( 'No Content Blocks found in Trash', 'custom-post-widget' ),
    		'parent_item_colon' => ''
    	);
    	$content_block_public = false;
    	$options = array(
    		'labels' => $labels,
    		'public' => apply_filters( 'content_block_post_type', $content_block_public ),
    		'publicly_queryable' => false,
    		'exclude_from_search' => true,
    		'show_ui' => true,
    		'query_var' => true,
    		'rewrite' => true,
    		'capability_type' => 'post',
    		'hierarchical' => false,
    		'menu_position' => null,
    		'supports' => array( 'title','editor','revisions','thumbnail','author' )
    	);
    	register_post_type( 'content_block',$options );
    }

    …and then the working filter:

    function filter_content_block_init() {
    	$content_block_public = true;
    	return $content_block_public;
    }
    add_filter('content_block_post_type','filter_content_block_init');

    Might not be the most elegant (I’m no PHP pro) but it works!

    Plugin Author Johan van der Wijk

    (@vanderwijk)

    Hi Jonah,

    I have updated the plugin with the suggested code. Could you please install and test this new version of the plugin: https://downloads.www.ads-software.com/plugin/custom-post-widget.2.5.3.zip

    Please let me know if this works!

    Thread Starter jonahcoyote

    (@jonahcoyote)

    Hey Johan,

    Looks good to me, thanks for adding it!

    – Jonah

    Plugin Author Johan van der Wijk

    (@vanderwijk)

    Great, I have just released the new version.

    Hi Jonah, Johan,

    thanks but it doesn’t work for me. I have VC and Custom Post Widget installed – added the function_ .. to my functions.php but I still do not see the custom posts available to select from in the visual composer. What am I doing wrong?

    Also – other plugins that have WP widgets do not appear in the visual composer by default – any idea?

    Thanks in advance,
    Seb

    Thanks guys, this was helpful.

    Using @jonahcoyote advise a new plugin has been built.
    You can download it for free at

    Using @jonahcoyote advise a new plugin has been built.
    You can download it for free at DeMomentSomTres

    Lovely enhancement! I was wondering if this was possible, and was very happy to read this post ??

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Make Post Type Public’ is closed to new replies.