Embed PDF into wordpress

The only reliable cross browser solution is to embed the .pdf in a iframe. add_filter(‘media_send_to_editor’, ‘my_pdf_embed’, 20, 3); function my_pdf_embed($html, $id) { $attachment = get_post($id); //fetching attachment by $id passed through $mime_type = $attachment->post_mime_type; //getting the mime-type if ($mime_type == ‘application/pdf’) { //checking mime-type $src = wp_get_attachment_url( $id ); //change the size to your liking … Read more

Exclude a category of posts in author template

Never use query_posts, use pre_get_posts to modify any main query. function wpd_exclude_author_category( $query ) { if ( $query->is_author() && $query->is_main_query() ) { $query->set( ‘category__not_in’, array( 42 ) ); } } add_action( ‘pre_get_posts’, ‘wpd_exclude_author_category’ );

Get post related to particular meta box? [closed]

Something along the lines of: $args = array( ‘posts_per_page’ => 10, ‘post_type’ => ‘post’, ‘meta_key’ => ‘METAkeyNAME’, //what I assume you’ve called a meta box ‘meta_value’ => ‘THEdesiredVALUE’, ‘orderby’ => ‘ID’, //choose to order by anything look here [http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters] for more info ‘order’ => ‘ASC’, ); $results = new WP_Query($args); // ‘<pre>’.print_r($results).'</pre>’; // This is … Read more

creating files for displaying different custom post type posts with paging

You don’t have to create any dummy page for custom post types, as those archive pages are just an automated process and named using the post type object name. To make sure your Custom Registered Post Type uses/support archive page, set the parameter ‘has_archive’ => ‘documents’ for Document & ‘has_archive’ => ‘videos’ for Video. register_post_type( … Read more

Change the background of each post according to the category

I do not know this theme. But you must use this two functions somewhere: get_theme_mod (‘background_image’, $default); set_theme_mod (‘background_image’, $_category_image_absolute_path); Maybe, you can define new modification names with this functions. For example, ‘backgroud_image_entertainment’, ‘background_image_storysode’, etc. (as is shown in the referred web page) by using set_theme_mod. set_theme_mod (‘backround_image_entertainment’, $_category_image_absolute_path); Then, you should add some functions … Read more

Echo the number of posts being displayed

rearrange your code and use post_count; example: <?php $movieNumber = 1; $today = date(‘Ymd’); $posts = array ( ‘post_type’ => ‘movie’, ‘posts_per_page’ => -1, ); $loop = new WP_Query( $posts ); ?> <div id=”posters<?php echo $loop->post_count; ?>”> <?php while ( $loop->have_posts() ) : $loop->the_post(); …etc…

WordPress Search

Your search form includes this: <input type=”hidden” name=”post_type” value=”postpage” /> So when your search page loads, the query variable ‘post_type’ is set to load posts of type ‘postpage’. Since posts are of type ‘post’ and pages are of type ‘page’, neither of which are ‘postpage’, you do not get what you expected. Next time, don’t … Read more

Different number of posts per row in grid layout

This can be achieved by making use of Masonry a Cascading grid layout library Which is included in WordPress since 3.5 and has been updated to v3 with the release of version 3.9 of WP. It really is a nice tool to accomplish different kind of grid layouts. Of course it isn’t necessary to use … Read more