On my new theme I’m coding into WordPress, I’m using custom post types for the homepage sliders.
I gave my custom post type the ability to edit the page attributes like order. But, for some reason, when I query them on the homepage, they don’t display in the order I specified within the custom post type.
If I view the custom post type page, it lists them in the order that I specified, but in the slider, it doesn’t show them in the order that I set them as. It still lists them according to date.
Does anybody know how I can fix this?
Here’s my code:
<?php $loop = new WP_Query( array( 'post_type' => 'slider_item' ) ); ?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
Now it does list it by order, but backwards for some reason? If I make a slide order 1 out of 3, it shows that one last, and the 3rd one first, and 2nd one second. So basically 321 instead of 123.
Now it does list it by order, but backwards for some reason? If I make a slide order 1 out of 3, it shows that one last, and the 3rd one first, and 2nd one second. So basically 321 instead of 123.
Know how I can fix this?
I think you need to set the order parameter to ASC (or possibly DESC)
When Wordpress resizes the image it will keep the aspect ratio of the original image. So if the ratio of the original image is different than 32:10, the image will just resize to a width of 960px and an auto height rather than distort or clip the image. Other than that, I have no idea what your problem is.
OK so there’s absolutely no way to resize thumbnails or remove the height="" and width="" from the code that WP outputs through the_post_thumbnail() function?
Also, I’m trying to add a custom section to pages where they can enter a page sub title. Here’s the code I have for the add_meta_box:
<?php
function admin_init_page_options(){
add_meta_box("pageInfo-meta", "Page Sub Title", "page_title", "page", "normal", "high");
}
function page_title(){
global $post;
$nav_span = get_post_meta($post->ID, 'page_title', true);
echo 'Page Sub Title:';
}
function save_page_title($post_id) {
global $post;
if(isset($_POST['post_type']) && ($_POST['post_type'] == "page")) {
$data = $_POST['page_title'];
update_post_meta($post_id, 'page_title', $data);
}
}
add_action('admin_init', "admin_init_page_options");
add_action('save_post', 'save_page_title');
?>
It’s not adding when I go to edit a page. Any clue why?
This is the code for adding custom sections to my custom post types. Do I need to change $post to $page or something?
All you’ve done is say to Google or check the codex. Trust me, I check the codex. That’s always my first resource but it doesn’t answer all of my questions. I tried using the code from the WordPress codex and it hasn’t worked for me.
So if you’d maybe like to help me instead of telling me to check the codex 50 times?