Populate editor with some content of a page with a page template

The is_page_template() function will not work in the admin. The second parameter of the default_content filter is the $post object. Your best bet is to leverage that to get the stored value for the page template in the post meta information: add_filter( ‘default_content’, ‘wpse_editor_default_content’, 10, 2 ); function wpse_editor_default_content( $content, $post ) { if ( … Read more

Page redirects to archive

It seems like you have the same slug “news” for custom post type and page. If it is the case, I would like to recommend to change the slug for custom post type to something like “cpt_news” or anyone that you think is best.

php page not found for plugin options menu

Looking at an old commit on a plugin I am writing, I am seeing a couple of things that jump out at me. First is your options page declaration. I had mine as follows, using your labels: function settings_menu_email() { add_menu_page( ‘Set Email’, ‘Set Email’, ‘manage_options’, ’email_admin_menu’, ’email_admin_menu_callback’, ); add_submenu_page( ’email_admin_menu’, __( ‘Options’, ‘textdomain’ ), … Read more

get_pages() & “child_of”

You are using it at wrong place, You can use the same function in page.php and if you want to use it in single.php then you have to pass static pageId as parameters. Right now you are passing $post->ID which will return post id of current article and Articles does not have any relation with … Read more

How can I get the homepage from the loop?

That depends on what your trying to do. If you want to get the page content in another template or functions file and your home page is a page that you created in the dashboard and set as the static front page you can use get_page_by_path function like this: get_page_by_path(‘the_path_of_the_page’); // Usually will be ‘home’ … Read more