How to restore permanently trash page? [closed]

The only way to restore it is to restore a backup of your MySql database. Login to your web host and see if there are any backups of your database available. Then you can restore the backup and it will bring that content back. Make sure you haven’t added any other content after the backup … Read more

wp_insert_posts keeps adding multiple pages

You can check whether the page exists or not, and create it only if it doesn’t already exist. get_page_by_title() can help you in this case: // Check if the page already exists if( ! get_page_by_title(‘My page Reql’) ) { // The page doesn’t exist, so let’s create it } Also, you might want to investigate … Read more

Cannot get grandparent object

just a small error. To get the parent and Grandparent objects, you need to get_post them also. The property “post_parent” only gives you the ID of that post, not the post_object itself. So you change your code like this: <?php $current = get_post($post->ID); //Conditional to be sure there is a parent if($current->post_parent){ $grandparent = get_post($current->post_parent); … Read more

custom posts on different page

Create a page, call it blog. Create a page template and fetch posts from the custom type. Attach the template to the page. Save. Example Page Template You can use any parameters in the query line that you would with query posts. <?php /* Template Name: Blog template */ get_header(); $blog_query = new WP_Query; $blog_query->query( … Read more

Want Page Title to show on menu, but not on page

A possible quick fix is to duplicate your page.php or index.php template file, rename it front-page.php, then open it and delete the_title(); and any html tags around it, like <h1> </h1> or whatever the title is wrapped in.

wordpress reusable content blocks

One of two ways: Add a shortcode, so someone could drop in [content-block id=”12″] wherever they wanted. Here’s a very simple example without a lot of error checking. <?php add_action( ‘init’, ‘wpse29418_add_shortcode’ ); function wpse29418_add_shortcode() { add_shortcode( ‘content-block’, ‘wpse29418_shortcode_cb’ ); } function wpse29418_shortcode_cb( $atts ) { $atts = shortcode_atts( array( ‘id’ => 0 ), $atts … Read more

How to add meta boxes to Pages

I’ve got this working finally ($template_file == ‘page-tjenester.php’), so now my meta boxes shows up only when I use this specific page-template! This is the final code if someone is interesting; add_action(‘admin_init’,’my_meta_init’); function my_meta_init() { $post_id = $_GET[‘post’] ? $_GET[‘post’] : $_POST[‘post_ID’] ; $template_file = get_post_meta($post_id,’_wp_page_template’,TRUE); if ($template_file == ‘page-tjenester.php’) { // this will only … Read more

How can plugins have their own pages?

Believe it or not the WordPress official documentation has a great page covering this topic called Administration Menus. It also provides example code on how to use WordPress hooks in your plugin code to add custom setting pages and other pages like that. The page can be found here. Fire up the kettle and make … Read more