Rory1984
-
Posts
6 -
Joined
-
Last visited
Posts posted by Rory1984
-
-
Hi,
I am editing a Wordpress child theme. I have an existing page template which displays all documents from the post type 'publications'.
I simply want to display a single category (id=29) from these posts.
I have been given the following code but the posts are not displaying on the page -
<?php $posts_per_page_option = ot_get_option( 'wpl_publications_per_page' ); ?><?php $posts_per_page = ( !empty( $posts_per_page_option ) ? ot_get_option( 'wpl_publications_per_page' ) : 10 ); ?><?php $args = array('post_type' => 'post_publications','post_status' => 'publish','posts_per_page' => 5,'cat' => 29,'paged'=> $paged); ?>
Any help much appreciated, thanks. -
The code is just missing the comma , after each line of the array in case anyone else needs to use it
-
Perfect, thank you so much, just in time to get it to my client!!
Rory
-
Thanks but that is displaying the full posts.
All the code does is identify the category and posts required which it then displays sections of below. I believe it should be something within the array, I tried this
$args = array(
'post_type' => 'cpt_issue',
'post_status' => 'publish',
'orderby' => 'date',
'order' => 'DESC'
'post__not_in' => array( $post->ID )
);but it has an error.
Can anybody help?
thanks,
Rory
-
Hi,
I have a PHP script that was written by somebody else but I need to edit, it displays the latest issue of a magazine on Wordpress.
What I need to do is show the 2 previous posts, excluding the most recent. So change the posts per page to 2, and then exclude the current post.
It's probably quite simple but I'm no PHP expert as yet.
Here is the script -
<?php if (have_posts()) : while (have_posts()) : the_post(); ?><main id="main"><section id="latest-edition"><div class="row"><?php$args = array('post_type' => 'cpt_issue','post_status' => 'publish','posts_per_page' => 1,'orderby' => 'date','order' => 'DESC');if($issues = get_posts($args)):foreach($issues as $issue):list($src,$w,$h) = wp_get_attachment_image_src(get_post_thumbnail_id($issue->ID),'full');?>Thanks for your help in advance,
Rory
Retrieving posts by category on Wordpress Archive
in Applications
Posted
Sorry I should have posted the full code:
It displays all the posts if I remove 'cat' => 29, from the array but will not display the posts from a category.
Any more ideas?
Thanks