Create a Page via plugin

You can create the page via wp_insert_post( $post, $wp_error );. The array $post contains the data for your page, with the full documentation here. Be sure to receive the ID from your inserted page/post. You can Add the page at the activation of your plugin, but please check first if the option for the page … Read more

wp_dropdown_pages default value

I would suggest, that you switch from “URl query argument” style to arrays. This is a “feature” that is more a left over on some functions that is only available for backwards compatibility reasons than anything else. Here’s a reworked version of your current arguments: wp_dropdown_pages( array( ‘title_li’ => ”, ‘depth’ => TRUE, // originally: … Read more

Add custom text at bottom of every page?

Depending on theme you are using there might be hooks available to output content at specific point. There is no generic convention for them, however. The most general approach to modifying the default output of page would be modifying (or introducing) page.php template. If your base theme is upstream (not developed for specific site) and … Read more

Template for child pages / subpages

Here is a basic idea: Any page where the page parent ($post->post_parent) is 0, it means the page is a top level page. If any other value exists, the page is a child of another page. This value is the ID of the page that the specific page is a child to. With the above … Read more

How to change URL Custom Page?

You’re using the reserved public query variable name as your custom one. It can e.g. affect the canonical redirect by setting page_id and name for a different page. Change it to something else to avoid possible name collision, like kenan_video_slug: add_rewrite_rule( ‘^watch/([^/]*)$’, ‘index.php?pagename=watch&kenan_video_slug=$matches[1]’, ‘top’ ); Note that your rewrite will override the content pagination for … Read more

How to exclude shortcode from specific page IDs if it’s set to global

Please try this and let me know the result function my_shortcode_to_a_post( $content ) { global $post; $disabled_post_ids = array(’20’, ’31’, ’35’); $disabled_tag_ids = array(‘5′, ’19’, ’25’); $current_post_id = get_the_ID(); // try setting it to $post->ID; if it doesn’t work for some reason if(in_array($current_post_id, $disabled_post_ids)) { return $content; } $current_post_tags = get_the_tags($current_post_id); if($current_post_tags){ $tags_arr = array(); … Read more

Print number of post (in reverse)

To print a decreasing counter for the main home query, without sticky posts, you can try: // current page number – paged is 0 on the home page, we use 1 instead $_current_page = is_paged() ? get_query_var( ‘paged’, 1 ) : 1; // posts per page $_ppp = get_query_var( ‘posts_per_page’, get_option( ‘posts_per_page’ ) ); // … Read more

How to re-order pages en-masse

First, the approach for setting up a sorting algorithm depends on where/how those street name and address numbers are stored. Single line in a meta_key, two separate meta_key entries, dumped into content for some reason, etc. etc. etc. OP is dealing with addresses stored as post_title values. So below assumes string like: 1234 Main Street … Read more