How to add user page with my plugin (3 posts)

  1. pstanev
    Posted 3 years ago #

    Hi I want to add userpage with my plugin i try like 10 different functions ,but non of them work.

    Here is picher of what i want to do when my plugin is on:

  2. bcworkz
    Posted 3 years ago #

  3. finnj
    Posted 3 years ago #

    Hi, i use the below code in my plugin to create the page that contains the shortcode for the plugin, if the page is not there already - mybe you can use some of it:

    // Check if page containing [frontier-post] exists already, else create it
    	$tmp_id = $wpdb->get_var(
    		"SELECT id
    		  FROM $wpdb->posts
    		  WHERE post_type='page' AND
    		  post_status='publish' AND
    		 post_content LIKE '%[frontier-post]%'
    	if ( ((int)$tmp_id) <= 0)
    		// Add new page
    		$my_page = array(
                     'post_title' 		=> 'My Posts',
                     'post_content' 	=> '[frontier-post]',
                     'post_status' 		=> 'publish',
    				 'comment_status' 	=> 'closed',
                     'post_type' 		=> 'page',
    		// Insert the page into the database
            $tmp_id = wp_insert_post( $my_page );
    	// save the page id so it can be reused in code and changed in settings
    	add_option("frontier_post_page_id", $tmp_id );

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.