Wordpress Custom Fields
- Started
- Last post
- 8 Responses
- mg33
Any of you Wordpress guys really skilled with custom fields, and more specifically the Advanced Custom Fields plugin?
http://www.advancedcustomfields.…
I use that plugin for custom pages now, but looking to do something more complex. I'm looking to create a page with custom fields, that pulls all thumbnails for portfolio posts into a grid. Needs to grow as more portfolio pages get added.
I can't use the site's current portfolio page for this, because the number of posts shown is connected to the number of blog posts that display on a separate page. Looking to isolate the controls for this new page from that and not mess with the blog.
Can anyone point me in the direction of what I need to code so that it gets all portfolio posts, and displays the info I need? I can handle the content display part (thumbs, heading, etc), I'm pretty good with that part.
Thanks!
- Centigrade1
you don't need the plugin for this... you need a new page with a custom template associated with it. Then query all the portfolio posts and grab the thumbnails from them.
- I do in some regards; there are custom fields in my portfolio posts now. Need to leverage those.mg33
- ah, then you can query the portfolio posts and grab the custom filed data... for images look here:
http://www.advancedc…Centigrade
- FallowDeer1
Sounds like you need to create a new custom post type?
- fadein110
Create a new custom post type and associate the custom fields with that post type.
Funny - I have just started using this to create better admin areas for clients.
- fadein110
Custom Post Type UI is a useful plugin to set everything up within Wordpress.
- mg330
Here's the thing. I might not be describing some of this the right way. In the admin screen, there's a Posts section, and a Portfolio section. Portfolios don't display in the blog, and blogs don't display in the portfolio.
There's a setting in Settings > Reading called "Blog pages show at most X" where X is currently 10. This same number applies to the existing portfolio pages.
I don't want to increase the number for both; I want to keep blogs at 10 per page, and for a new custom portfolio page (or modified existing page, which is turned off on the site now), I want unlimited per page.
That's why I'm figuring that I can leverage the existing portfolio content on a new page. That might not even require custom fields, except for leveraging what I've already added to existing portfolios.
- Centigrade0
Are you coding this with PHP? Or just using a sersies of plugins to help you?
It's easy to increase the number of posts shown if you are writing page templates with php.
Use a loop like so:
<?php
$args = array(
'post_type' => 'YOUR POST TYPE HERE',
'posts_per_page' => 1000,
);
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();?>DO YOUR LAYOUT TUFF FOR EACH POST
<?php endwhile; ?>
---
The key part is the posts per page... you can change that number to whatever you want.
- mg330
Centigrade,
Thanks again for posting that. Helped me look around existing pages and I lucked upon realizing that I can grab existing code used on the homepage template and repurpose it:
<?php
$args = array(
'post_type'=>'portfolio',
'showposts'=> 6
);$temp = $wp_query;
$wp_query = null;$wp_query = new WP_Query();
$wp_query->query( $args );?>
<?php if ( $wp_query->have_posts() ) : ?>
-------------USE EXISTING CODE FOR THUMBNAIL DISPLAY----------
<?php endwhile; ?>
</ul><!-- .fromportfolio-items -->
</div> <!-- .portfolio-items-wrap -->
</section><!-- #fromportfolio -->
<?php endif; wp_reset_query(); $args = null; ?>
- mg330
A few more things:
My main goal is to change the layout of http://www.expeditionbureau.com/… (which isn't used on the live site, but is an existing theme page) to be more like http://www.expeditionbureau.com/…, which is a custom page I created last year, because I want the descriptions to display for each feature. If I can modify the current portfolio page, I've got the advantage of pagination already built in to avoid pages being too long. I just can't find where exactly that portfolio page lives in the theme structure.
The issue page uses custom fields for thumbnail, link, overview, and name. I would start integrating anything not available in a portfolio post into portfolios as a custom field, and just access it via the PHP.
- /portfolio is using archive.php or archive-portfolio.ph...
https://developer.wo…estetic - ^ nice, that's a great chart. Thanks!mg33
- estetic - you're right - I found that easily. So if archive.php is this page, what is the archive page for blogs?mg33
- Looks like page.php or page-blog-page.php, something like that - bit of a weird setup, did you do the original build?estetic
- Inspecting the source and looking at the body tags is a good place to start when chasing template routingestetic
- Thanks again. It's usually easier than this, and I haven't worked on modifying this theme in a couple years.mg33
- /portfolio is using archive.php or archive-portfolio.ph...