Isn’t the way posts are displayed very unefficient?
you could move the loop content into its own file and share that between the different template files using get_template_part()
you could move the loop content into its own file and share that between the different template files using get_template_part()
Weird Problem!, try the following: Make sure that the targeted categories are not empty. If you are using custom post type,include it in the query ‘post_type’=>’advertisement’ for example. If the targeted categories are special taxonomies,make sure to include it in the query : ‘term’=>’cars’ along with child ‘cars’=>’toyota’. in this example and just to make … Read more
<?php add_action( ‘init’, ‘wpse31629_init’ ); function wpse31629_init() { add_post_type_support( ‘post’, ‘page-attributes’ ); } Add that to your functions.php or in a plugin file and you’ll get an attributes dialog box with the menu order input.
Let’s presume your FILE variable is called ‘files’ and can contain multiple inputs (i.e. name=”files[]”) 1) First upload the files $uploads = wp_upload_dir(); $upload_file_url = array(); foreach ($_FILES[‘files’][‘name’] as $key => $value_data) { $errors_founds=””; if ($_FILES[‘files’][‘error’][$key] != UPLOAD_ERR_OK) $errors_founds .= ‘Error uploading the file!<br />’; if (!array_key_exists($_FILES[‘files’][‘type’][$key], $mime)) $errors_founds .= ‘Invalid file type!<br />’; if … Read more
Delete or rename index.html as it’s the default file served if it’s available. This should then allow the server to start displaying your site files.
To check for the existence of a post type, use post_type_exists. For instance like this: if ( ! post_type_exists( ‘yourpt’ ) { $args = array( // your new post type’s arguments ); register_post_type( ‘yourpt’, $args ) } As for the prefix, that’s a matter of personal taste and how common you think the post type … Read more
This is a simpler solution, if you want a total control over the code and don’t want to use a query. $authors = get_users(‘role=author’); if(isset($authors) && !empty($authors)) { echo “<ul>”; foreach($authors as $author) { $posts = get_posts(array(‘author’=>$author->ID)); //if this author has posts, then include his name in the list otherwise don’t if(isset($posts) && !empty($posts)) { … Read more
You can do this easily using the edit_posts_per_page hook or edit_{$post_type}_per_page hook for pages and custom post types You can change based on the user role: function my_edit_post_per_page_role_based( $per_page, $post_type ) { //admin sees 25 posts per page if (current_user_can(‘administrator’)){return 25;} //editor sees 20 posts per page elseif(current_user_can(‘editor’)){return 15;} //author sees 10 posts per page … Read more
Try this using the get_children function: global $post; $args = array( ‘numberposts’ => -1, ‘order’=> ‘ASC’, ‘post_mime_type’ => ‘image’, ‘post_parent’ => $post->ID, ‘post_status’ => ‘any’, ‘post_type’ => ‘attachment’ ); $attachments = get_children($args); Reference: http://codex.wordpress.org/Function_Reference/get_children
Are you using the main query or a custom WP_Query for displaying the posts? If so : $wp_query->found_posts; //Main query $wp_query->current_post; // current post index or $my_wp_query->found_posts; //custom wp_query object – total found posts $my_wp_query->current_post; // current post index So, example if( have_posts() ) : while( have_posts() ) : the_post(); ?> <p>The post <?php the_title(); … Read more