Custom post types not using archive structure
You can always try to filter rewrite_urls array and create rules for you custom post type.
You can always try to filter rewrite_urls array and create rules for you custom post type.
$args = array( ‘numberposts’ => 3, ‘offset’ => 5 ); $posts = get_posts( $args ); foreach( $posts as $post ){ setup_postdata( $post ); [output the post here with the_title(), the_content(), etc] } If you search in the codex with ‘query posts’, you will find a lot.
You don’t need to create a page template to list the project post type, just go to /project/ and you’ll have a full date ordered listing. The template powering that page will be determined as follows: archive-project.php archive.php index.php So create an archive-project.php in your theme. Using this you can specify to list only the … Read more
Ok. You are toggling your display according to a $_GET parameter that you have added to the URL– this switch in your archive.php $view = ‘poster’; $mode = stripslashes( $_GET[“afisare”] ); $modes = array(‘complex’, ‘simple’, ‘poster’); if(in_array($mode, $modes)) $view = $mode; get_template_part(‘persoane’, $view); You can alter how many posts will display but that is much … Read more
is_single() returns TRUE or FALSE, not a string. Additionally, you can test for a specific post with is_single() function by putting the post slug into the function call: if ( is_single( ‘your-post-slug’ ) ) { # do something } If you want to test for the proper post type use: if ( is_singular() and ‘your-post-type’ … Read more
You can achieve that by changing the conditional to if ( !is_home() && !is_archive() ) Also consider using if and else if. So your optimized code would be: <?php if ( !is_home() && !is_archive() ) { if ( get_post_type() == ‘pretty-little-liars’ ) { echo ‘<div id=”headerimg”><img src=”http://tv-cafe.com/wp-content/uploads/2013/01/pllbanner.png”></div>’; } else if ( get_post_type() == ‘revenge’ ) … Read more
I found the actual answer in a stackoverflow question. Quoted from the answer: <?php $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; $args = array( ‘post_type’ => ‘post’, ‘posts_per_page’ => 10, ‘paged’ => $paged ); $wp_query = new WP_Query($args); while ( have_posts() ) : the_post(); ?> <h2><?php the_title() ?></h2> <?php endwhile; ?> <!– then the pagination … Read more
What I’m trying to do is make a separate page on the site that lists all posts (not sorted by tag/category/year) in a single, easily-accessible portion of the site by just going to /archive (e.g. www.example.com/archive) The correct approach is, indeed, to create a custom page template, so that the user can create a static … Read more
Ok so I sorted the issue for now by using – $queried_object = get_queried_object(); $term_id = $queried_object->term_id; instead of – $tags = wp_get_post_tags($post->ID); $first_tag = $tags[0]->term_id; Any comments?
As you can see in this image, template hierarchy limits to taxonomy-$taxonomy-$term.php. I don’t know why a subterm falls back to taxonomy-$taxonomy.php, but I guess it searches for a taxonomy-$taxonomy-$term.php in wich $term would be workshops, science labs and so on. And since those don’t exist (I suppose), it falls back on taxonomy-$taxonomy.php. You could … Read more