Show a list of recently viewed posts to a user

This plugin may fulfill your requirements. http://wordpress.org/extend/plugins/recently-viewed-posts Usage get_recently_viewed_posts( $max_shown = 10 ) returns a string of li’s. recently_viewed_posts( $max_shown = 10 ) prints a div If you are interested in learning how to develop this functionality yourself, download the plugin and see the source files. WordPress is Open Source! Update: The above plugin did … Read more

Show post titles only on the homepage

If the posts are already shown on your page, just with a bunch of unnecessary text that you want to take away, do the following: 1. Open the template file of your homepage (it can be named different in different themes, so impossible to give you the exact name of file, but usually they are … Read more

Create A Metabox For A Custom Field

This will create a metabox for you to enter a video code. //Creating a MetaBox for Posts to enter Video Code. add_action(‘add_meta_boxes’,’video_meta_box’); function video_meta_box(){ add_meta_box(‘video_box_id’, ‘Enter Video ‘ , ‘video_box_cb’,’post’,’normal’,’default’); } function video_box_cb($post){ $value = get_post_meta($post->ID,’video_box’,true); echo ‘<textarea rows=”4″ cols=”50″ id=”video_box”, name=”video_box”>’; echo $value; echo ‘</textarea>’; } add_action(‘save_post’,’save_video_box’); function save_video_box($post_id){ $box_data = $_POST[‘video_box’]; update_post_meta($post_id,’video_box’,$box_data); } … Read more

Dynamic HTML not displaying at respective place

You’re getting the output there because dynamic_sidebar() displays/echoes the output (widgets in the specific sidebar), so the output is echoed right when the shortcode function is called, which is before the $data is actually echoed. And you can fix that using output buffering: Either append the output to $data: $data.='</div>’; $data.='<div class=”col-xl-4 col-lg-4 col-md-4 col-sm-12 … Read more

eBooks download website, page or post?

Pages are relatively more static. They don’t change much. Posts on the other hand do change on a regular basis. Just like any store, it’s best to use posts in this case. You can also create a custom post type and call it “ebooks”. It would be more appropriate, but posts can do fine.

Show One Category on Post

Thank you for your question. Try using the following code. <?php $categories = get_the_category(); if($categories[0]) { $url = get_term_link((int)$categories[0]->term_id,’category’); $temp = “<dt><h1>{$categories[0]->name}</h1> </dt><dd>{$categories[0]->category_description}</dd>”; echo “<dl>\n” . $temp . “\n</dl>”; } ?> Best Regards, Vinod Dalvi

How to add padding between posts

WordPress already generates class for each posts, you can use these classes using the post_class function. Note: The function can be used either within the loop or by passing the $post_id So you would have <ul> <?php $the_query = new WP_Query( ‘posts_per_page=5’ ); ?> <?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?> <div … Read more

Filter/Remove HTML Elements on all posts and pages

Here’s an example function that might help you accomplish something like that. Basically what it does is fetch a couple of posts, loops through them, modifies the post_content field and stores the changes. function wpse_87695_clean_post_content() { $posts = get_posts(array( ‘post_type’ => array(‘post’, ‘page’), ‘post_status’ => ‘publish’, /* ‘meta_query’ => array( array( ‘key’ => ‘_wpse_87695_processed’, ‘value’ … Read more

how to show all post in my page-grid.php template page

<?php $args = array( ‘post_type’ => ‘put your custom PostType name here’, ‘posts_per_page’ => ‘-1’ ); $query = new WP_Query( $args ); if ( $query->have_posts() ) { while ( $query->have_posts() ) { $query->the_post(); // Contents of the queried post results go here. } } // Restore original post data. wp_reset_postdata(); ?>