Can I change a post to a page by changing it’s type?

Changing the post_type property of a post is easy, but there are a few con’s you would need to consider here before doing so Non hierarchical post types (like post) behaves way different that hierarchical post types (like page). I’m not going to explain everything here, but in general, most importantly, non hierarchical post types … Read more

Should I use relative or absolute urls when pointing to internal pages

It depends on what you’re talking about. If you’re talking about using just <a href=”https://wordpress.stackexchange.com/page-title”>Page Title</a>, then no. It’s better to use the full link. However, instead of using http://www.domain.com/page-title, it’s better to use <?php echo bloginfo(‘url’); ?>/page-title. The reason you don’t want to use relative links is the way wordpress permalinks work. If you’re … Read more

Hide Visibility Option From WordPress Publish Metabox

Add this code: function wpseNoVisibility() { echo ‘<style>div#visibility.misc-pub-section.misc-pub-visibility{display:none}</style>’; } add_action(‘admin_head’, ‘wpseNoVisibility’); to functions.php of your active theme. Needless to say, the preferred method, would be to add above code to functions.php of the child theme. Update Unfortunately, the above solution will not limit this change to pages only. We’ll have to determine, if we add, … Read more

wp_link_page – wrap current page element

I wouldn’t use WordPress’ internal function. We had a very similar question recently: How to style current page number (wp_link_pages)? I wrote a small but flexible function to replace wp_link_pages(). It is probably easier to extend this than hacking around the return value of the native function.

Get parent page/menu id of current post

I believe you want get_queried_object. If you have set your static front page and blog page from wp-admin->Settings->Reading then get_queried_object will give you information about the page you chose rather than about the posts in the Loop. Be aware that get_queried_object will return very different types of information depending on the kind of page you … Read more

Debugging shortcode problems

As @Milo said, wordpress.com is a platform on its own, and everything available on wordpress.com is only available to sites hosted on wordpress.com. The jetpack plugin does however make some features available to self hosted sites but I’m not particulary sure which ones. The shortcodes you are talking about is only available on sites hosted … Read more

Hide pages depending on role

To get the current role of the user $current_user = wp_get_current_user(); if ( !($current_user instanceof WP_User) ) return; $roles = $current_user->roles; //$roles is an array After getting role set page ids which you want to show according to roles (for example) if($roles==’administrator’){ $args=array(’21’,’22’,’23’); } or if($roles==’subscriber’){ $args=array(’24’,’25’,’26’); } you can use parse_query filter hook to … Read more

WP-PageNavi plugin doesn’t work with multiple pages of search results

I discovered that the problem was in my theme’s searchform.php file. I changed the form method from “post” to “get.” Now search queries show up in the url address. Before: <form action=”<?php echo $_SERVER[‘PHP_SELF’]; ?>” method=”post”> After: <form action=”<?php echo $_SERVER[‘PHP_SELF’]; ?>” method=”get”> Problem solved.