Maximiadis
Forum Replies Created
-
Forum: Plugins
In reply to: [Custom Post Type UI] Using CPT in WordPress core categoriesBelow is the code from my now_showing.php file.
<?php query_posts('category_name=now-showing'); if (have_posts()) : while (have_posts()) : the_post(); ?> <section> <div class="wrapper"> <article> <?php if (has_post_thumbnail()) { the_post_thumbnail('medium'); } ?> <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> </article> </div> </section> <?php endwhile; endif; ?>In the past I have just queried the CPTUI through all the posts regardless of what category (if any) the posts where assigned to, using
query_posts('post_type=>logo_design');then I just went through the normal loop on a custom php file. The problem is, if I did use the post_type query then the post expiry plugin I’m using wouldn’t be very useful in changing and displaying the posts category from the CPTUI e.g. “Now Showing” to “Past Events” categories. And to add more complexity, each CPT has different custom fields for the client, to simply add their content, knowing it will be displayed in the front-end in a set way.Forum: Fixing WordPress
In reply to: How to call specific pages in one page“Solved”
This is for anyone that might be having the same problem.The code below will only work for children of the page you are viewing currently which for me was the home page.
<?php $posts = get_pages( array( 'child_of' => $post->ID, 'sort_column' => 'post_date', 'sort_order' => 'DESC' ) ); foreach( $posts as $post ) : ?> <article> <h1><?php echo apply_filters( 'the_title', $post->post_title, $service->ID ); ?></h1> <?php echo get_the_post_thumbnail( $post->ID, 'thumbnail' ); ?> <?php echo apply_filters( 'the_content', $post->post_content ); ?> <a href="<?php echo get_page_link( $post->ID ); ?>"><?php echo View ?></a> </article> <?php endforeach; ?>The code below is more specific to what I needed, which requires a database query.
<article> <?php $querystr = " SELECT wposts.* FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta WHERE wposts.ID = wpostmeta.post_id AND wpostmeta.meta_key = 'what-we-do-descriptions' AND wposts.post_type = 'page' ORDER BY wpostmeta.meta_value DESC "; $pageposts = $wpdb->get_results($querystr, OBJECT); ?> <?php $pageposts = get_pages( array( 'child_of' => $post->ID, 'sort_column' => 'post_date', 'sort_order' => 'DESC' ) ); ?> <?php foreach ($pageposts as $post): setup_postdata($post); ?> <h2><?php the_title(); ?></h2> <div> <?php if (has_post_thumbnail()) { the_post_thumbnail('thumbnail'); } ?> </div> <a href="<?php the_permalink() ?>" rel="bookmark" title="View more about <?php the_title_attribute(); ?>">View</a> <div> <?php the_field('what-we-do-descriptions'); //can only display this after looking through all posts/pages with this "custom key type" ?> </div> <?php endforeach; ?> </article>Forum: Fixing WordPress
In reply to: How to call specific pages in one pageThis is the closest I’ve come to solving my problem. However I’m still not getting the output I need.
<?php $services = get_pages( array( 'child_of' => $post->ID, 'sort_column' => 'post_date', 'sort_order' => 'DESC' ) ); foreach( $services as $service ) { $content = $service->post_content; //$description = $service->the_field('what-we-do-descriptions'); $thumbnails = $thumbnail->has_post_thumbnail; if (has_post_thumbnail()) { // check if the post has a Post Thumbnail assigned to it. the_post_thumbnail('medium'); } //if ( ! $content ) // Check for empty page //continue; //$content = apply_filters( 'the_content', $content ); ?> <h2><a href="<?php echo get_page_link( $service->ID ); ?>"><?php echo $service->post_title; ?></a></h2> <div class="entry"><?php echo $content; ?></div> <div class="entry"><?php echo $thumbnail; ?></div> <?php } ?>Forum: Fixing WordPress
In reply to: How to call specific pages in one pageI’ve looked at the template hierarchy page you shared and it doesn’t help me, sorry.
My php skills are somewhat limited, but I can understand the basics of what I’m looking at. I’ve tried searching for some php code that might be similar to what I need, but all I can find is how to list all the pages and their content that I’ve created, which is not what I want.