Allowing user to edit only certain pages

The first thing to do to implements such task is to be able to recognise which page an user can edit. There are different ways to do it. It could be a user meta, some configuration value… For the sake of this answer, I will assume that a function lile this exists: function wpse_user_can_edit( $user_id, … Read more

Get the content of a specific page (by ID)

<?php // would echo post 7’s content up until the <!–more–> tag $post_7 = get_post(7); $excerpt = $post_7->post_excerpt; echo $excerpt; // would get post 12’s entire content after which you // can manipulate it with your own trimming preferences $post_12 = get_post(12); $trim_me = $post_12->post_content; my_trim_function( $trim_me ); ?>

Get the Current Page Number

When WordPress is using pagination like this, there’s a query variable $paged that it keys on. So page 1 is $paged=1 and page 15 is $paged=15. You can get the value of this variable with the following code: $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; Getting the total number of pages is a bit trickier. … Read more

Page template query with WP_Query

UPDATE: This is now a decade old answer, meant for a very old version of WordPress. I can see the comments informing me that this might not work for newer WP versions, please do refer to the other answers below if mine is not working for your version of WP. For WP 2.*, this will … Read more

Get page id by template

When a page is created, the assigned template to that page is saved as custom post meta in the same way as custom fields. The meta_key is _wp_page_template and the meta_value will be the page template You can simply make use of get_pages to retrieve all pages which have a meta_value of the specified template … Read more

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