Overriding the currently selected menu item

Since I assume you’re using wp_nav_menu(), there should be a class current_page_parent which is applied to your posts’ page menu item when viewing a single post. You can use this class to style the ‘active’ state, much like you’re probably doing with current_page_item at the moment. If (for whatever reason) you must have current_page_item added … Read more

Clean URL link for page without number

This is because your site already has a post or page (6 in your case) with the slug “photo.” They might be in the trash, or pending as drafts, or whatever … but WordPress automatically appends number to prevent name conflicts. So go through your site, and figure out which other pages are trying to … Read more

meta_key & meta_value not working with get_pages and custom taxonomy

Custom taxonomies are not meta values, but rather their own thing. I don’t think wp_list_pages() or get_pages() can query based on a taxonomy, so I’d recommend using WP_Query instead: <?php $relevant_pages_args = array( ‘post_type’ => ‘page’, ‘posts_per_page’ => -1, ‘post_parent’ => 65, ‘tax_query’ => array( array( ‘taxonomy’ => ‘relevance’, ‘field’ => ‘slug’, ‘terms’ => ‘alumni’ … Read more

Calling custom fields for pages (not posts)

try using get_metadata(‘post’, $postid, ‘teaser-text, true); these two actually same. should not make any difference. earlier i gave wrong arguments. var_dump() will show you what it is actually getting. please make sure, the ID is correct, ‘teaser-text’ exists. You can also try using some other meta name (for testing purpose only).

How can I display widget in a Page or Post?

There’s no easy way to do this. Many plugins that provide a widget also provide a shortcode (text in brackets that you can put in your post like this: [quora]). I have no idea whether either of your widgets also come with shortcodes. Though I’ve never used them, there are some plugins that claim to … Read more

Get closest page ID from URL

You should be able to get the current url from $url = add_query_arg(). Then assuming, the structure: www.example.com/page/subpage/news/ID/post you can use preg_match to extract /page/subpage/news. Then it would be simple matter of using get_page_by_path();. If that fails you can then check /page/subpage/ and finally /page.

How to create a metabox that will list all my pages in a dropdown selector?

You can use wp_dropdown_pages. For example add_action( ‘add_meta_boxes’, ‘myplugin_add_custom_box’ ); /* Adds a box to the main column on the Post edit screens */ function myplugin_add_custom_box() { add_meta_box( ‘myplugin_sectionid’, __( ‘My Post Section Title’, ‘myplugin_textdomain’ ), ‘myplugin_inner_custom_box’, ‘post’ ); } /* Prints the box content */ function myplugin_inner_custom_box( $post ) { $dropdown_args = array( ‘post_type’ … Read more

Custom Blog Post Page

When you set a page to be the page for posts it no longer operates like a vanilla page, the template hierarchy dictates a different set of templates for that page. Your selected template doesn’t appear to work, because it’s not being loaded. See the template hierarchy for more info. You should name your template … Read more

How do I create a separate page for each author?

Create an author.php template by copying your themes archive template to start with. Then you can modify it as you wish. WordPress will use this author template for every author on your site automatically As an example visit damien.co/author/damiensaunders Note you may have to change your authors names as Damien (space) Saunders doesn’t become damien%20saunders … Read more