WordPress giving a 404 page when passing a year argument different than the current year
Ok the problem was with using ‘year’ as the argument name, if I changed it to something else such as ‘y’ it seems to work.
Ok the problem was with using ‘year’ as the argument name, if I changed it to something else such as ‘y’ it seems to work.
I took a quick peek at the other question referenced in other comments, and the gist of how you loop through attachments there meshes with what is shown in the wp_get_attachment_image documentation example. In a nutshell, any attachments on a particular post will reference that post by ID. In particular, it’s crucial to understand that … Read more
Try just using the traditional $i iterator (untested) but I can’t see why this wouldn’t work.. <?php $i = 0; while ( have_posts() ) : the_post(); $i++; if ( $i == 1 ): ?> <!– First Post –> <div id=”post”> <a class=”post_image” href=”https://wordpress.stackexchange.com/questions/165568/<?php the_permalink(); ?>” title=”<?php the_title(); ?>”> <?php if ( has_post_thumbnail() ): ?> <?php … Read more
If I understand your needs correctly, you would like to have your /blog page and post items aggregated and driven by WordPress without exposing the user to anything WordPress. To solve the problem with “wordpress” being in the url, you should actually be putting the entire contents of the WordPress install into the website.tld/blog directory. … Read more
When the instance of WP_Query is not a variable on the PHP file you are working on it tends to be the “main” query and to edit this instance of the WP_Query you will need to Hook to the pre_get_posts action and change what you need there. Here is an Exemple: <?php add_action( ‘pre_get_posts’, ‘q166401_pre_get_posts’, … Read more
I’m not in the position to code right now, but here is an idea A thousand posts is quite a lot, but it is even more if you are retrieving all posts from the db in one go. What if you have ten thousand posts, of which only ten or twenty is not tagged after … Read more
I suggest just making a new Post Type with the default WordPress register_post_type(). function create_my_post_type() { $labels = array( ‘name’ => __( ‘Providers pricing’, ‘myplugin_namespace’ ), ‘singular_name’ => __( ‘Provider pricing’, ‘myplugin_namespace’ ), ‘menu_name’ => __( ‘Provider Pricing’, ‘myplugin_namespace’ ), ); $args = array( ‘labels’ => $labels, ‘public’ => true, ‘description’ => __( ‘Pricing stuff … Read more
The problem probably comes from whenever a $post has no terms set. You need to set $brand = array() outside your IF statement, add it just under get_the_terms(). At that point it also wouldn’t hurt to wrap your switch statement in a if( ! empty( $brand ) ) { Another problem I see with this … Read more
Use the page number to calculate a new date to get the week to fetch: $page = ( get_query_var( ‘paged’ ) ) ? get_query_var( ‘paged’ ) : 1; $date_to_fetch = time() – ( 604800 * ( $page – 1 ) ) ); $query_string = array( ‘post_type’ => ‘post’, ‘date_query’ => array( array( ‘year’ => date( … Read more
In your functions.php you can create a function that will hook into the pre_get_posts hook. Something like (just an example): function alter_query($query){ $query->set(‘post_parent’, 0); } add_action( ‘pre_get_posts’, ‘alter_query’ ); There you can alter the main query. That way while(have_posts()) : the_post(); will still just normally work. (You should check if you are altering the right … Read more