Is it possible to activate page template without manually selecting it in wp-admin?
Presumably you are using wp_insert_post to create your pages. Having done so, do update_post_meta($id, ‘_wp_page_template’, ‘my_template.php’);
Presumably you are using wp_insert_post to create your pages. Having done so, do update_post_meta($id, ‘_wp_page_template’, ‘my_template.php’);
Duplicate your page.php template, name the duplicate page-facebook.php, give it a template name: /* Template Name: My Facebook Meta Key Page */ More information here: http://codex.wordpress.org/Page_Templates To get the right posts with get_posts use something like this: <?php $args = array( ‘post_type’ => ‘post’, ‘meta_query’ => array( array( ‘key’ => ‘facebook’, ‘value’ => ‘yes’, ) … Read more
As @Rarst said, use PHP code inside a post content is bad habit. But you can use another workaround to show a section only for appropriate users. Add the following code into your functions.php file: add_shortcode( ‘if_user_can’, ‘wpse8170_show_content_if_user_can’ ); function wpse8170_show_content_if_user_can( $atts, $content=”” ) { $atts = shortcode_atts( array( ‘capability’ => ‘edit_posts’ ), $atts ); … Read more
wp_list_pages will output all of the pages, posts, and CPTs that you wish. You even have control over the CSS classes, some of which are already there: All list items (li) generated by wp_list_pages() are marked with the class page_item. When wp_list_pages() is called while displaying a Page, the list item for that Page is … Read more
Content in a page can come there in four ways in WordPress: In-page Content: That’s coming from the WordPress’ site’s page content itself. In this case you have to edit the page in your /wp-admin. Page Template: That’s coming from a page template. In this case, you have to get into your theme folder to … Read more
What you are doing is incredibly dangerous. You can break your site horribly, or have your entire server hacked. With a PHP in content plugin there is nothing stopping an editor from copy pasting a PHP shell in to the content editor and taking full control of your site. If you have content on a … Read more
You can try something like this. This will check if a page has child pages and if it does then it will redirect the first page in array ordered by menu order. // get child pages $child_page = get_pages( “child_of=” . $post->ID . “&sort_column=menu_order” ); if ( $child_page ) { // get id of first … Read more
I believe you’re looking for this: get_page_children() That function will return an array of your sub-pages, which you can iterate through to display your list.
Try using get_post_ancestors. Here is how you can apply this in your case: <?php global $wp_query; $post = $wp_query->post; $ancestors = get_post_ancestors($post); if( empty($post->post_parent) ) { $parent = $post->ID; } else { $parent = end($ancestors); } if(wp_list_pages(“title_li=&child_of=$parent&echo=0” )) { wp_list_pages(“title_li=&child_of=$parent&depth=1” ); } ?> You’ll probably need to remove the depth parameters to show you’re 3rd … Read more
You can use the page_attributes_dropdown_pages_args filter to remove whatever you want. It’s based off of the wp_dropdown_pages() arguments so you can use the exclude parameter to remove certain pages or a fake parent to remove all the pages: /** * Filter the arguments of Page Attributes Parent Dropdown * * @param Array $args – List … Read more