How to create a page and display only the posts with a specific custom field value?

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

How to use is_admin in page content?

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

How to list a page tree?

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

How to edit a HTML list in WordPress?

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

Redirect page to default subpage

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

Get parent of current page

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

Edit Parent page drop menu when creating a page

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

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)