Export only pages and posts with mysql dump

This is generally not a good idea. See this WordPress database diagram. You need to consider: posts that have categories or tags (terms), their relationships, term meta, and taxonomies posts that have authors (users) posts that have comments things that are actually posts that you might not realise are posts (eg. almost everything in WordPress … Read more

How to change redirect after moving a page to trash?

Hook into load-{screen_id} and check if the $_GET[‘trashed’] variable is 1 or above. add_action(‘load-edit.php’,’wpse_trashed_redirect’); function wpse_trashed_redirect(){ $screen = get_current_screen(); if(‘edit-page’ == $screen->id){ if( isset($_GET[‘trashed’]) && intval($_GET[‘trashed’]) >0){ $redirect = add_query_arg(array(‘page’=>’custom_page_oder’, ‘trashed’ => false, ‘ids’ => false )); wp_redirect($redirect); exit(); } } } This works – and I’m not aware of a better way of doing … Read more

Using JavaScript and JQuery in Page

jQuery is default active in WP, no need to enable it. There are 2 ways of including your own jQuery in WP: Enqueue your own file containing the jQuery (preferred method) Use the wp_head or wp_footer action hook to include a script with jQuery. I’m only going to explain how to enqueue scripts in WP. … Read more

How to get the list of posts in a static page other than front page?

The way I retrieve posts on my blog is to use the following: <?php $recentPosts = new WP_Query(); $recentPosts->query(‘showposts=5&cat=CAT_ID_GOES_HERE’); while($recentPosts->have_posts()): $recentPosts->the_post(); ?> Then you would go and create the code to control the display of each post. So for a really simple example: <h1 class=”title”><a href=”https://wordpress.stackexchange.com/questions/3170/<?php the_permalink(); ?>”><?php the_title(); ?></a></h1> Then at the end of … Read more

Why is custom template not seen as page with is_page()?

When you call query_posts($query); in your second template, you overwrite the global variable that WordPress uses to return the correct values for the is_ conditionals. You should basically never use query_posts in the template. For secondary loops, use a new instance of WP_Query instead.

How To Display Date (/Time/Author) In pages?

WordPress has some nifty functions which do this for you. You’ll need some experiences with HTML, CSS, PHP to style the output and understand what these functions do but the functions you’re looking for are: the_date() which displays the post date. the_author() which displays the author of the post. In your theme will most likely … Read more

How to disable Page Attributes dropdown in wp-admin

Removing support for page attributes will prevent that box from appearing… function remove_page_attribute_support() { remove_post_type_support(‘page’,’page-attributes’); } add_action( ‘init’, ‘remove_page_attribute_support’ ); … but I don’t know if you need attributes support or not. If you don’t that is the fix. If you do, you will need to remove the box as per @KrzysiekDrozdz’s answer, but to … Read more

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