-
Taxonomy archive page not showing any posts
Thanks. As far as I know it should just work because the template file name is performing all the arguments that it needs. Haven't had this problem before and never had to run a custom WP_Query in a taxonomy template before. Regardless, i've opted to go this route instead. Here's my code which is now doing what it should be: <?php $current_tax = $wp_query->query_vars['portfolio_categories']; $args = array( 'post_type' => 'portfolio', 'portfolio_categories' => $current_tax ); $wp_query = null; $wp_query = new WP_Query(); $wp_query->query($args); if ($wp_query->have_posts()) : while($wp_query->have_posts()) : $wp_query->the_post(); $image_id = get_post_thumbnail_id(); $image_url = wp_get_attachment_image_src($image_id); $image_url = $image_url[0]; ?> <a href="<?php echo $image_url; ?>" class="portfolio-item"> <?php the_post_thumbnail('portfolio-thumb'); ?> </a> <?php endwhile; endif; ?> Thanks for your help!
-
Taxonomy archive page not showing any posts
Yup, it's getting all the terms just fine, outputting their images and the links to the archive pages as it should be. The problem isn't on the archive-portfolio.php page though - it's on the taxonomy-portfolio_categories.php file where it outputs the single_cat_title(); but not any of the posts associated with that taxonomy.
-
Taxonomy archive page not showing any posts
Hi All, I have a custom post type with a few posts in and a custom taxonomy associated with it. My aim is this: To show a list of all taxonomies within the custom post type as images (done so using the 'Categories Images' plugin), which works fine on the main archive-portfolio.php custom post type template. These images then link to an archive of posts from that taxonomy using the taxonomy-portfolio_categories.php custom taxonomy template. My code for setting up the custom post type and taxonomy is this: <?php // Portfolio Custom Post Type: 'Portfolio' function portfolio() { register_post_type( 'portfolio', /* (http://codex.wordpress.org/Function_Reference/register_post_type) */ array( 'labels' => array( 'name' => 'Portfolio', /* This is the Title of the Group */ 'singular_name' => 'Portfolio Item', /* This is the individual type */ 'all_items' => 'All Portfolio Items', /* the all items menu item */ 'add_new' => 'Add New', /* The add new menu item */ 'add_new_item' => 'Add New Portfolio Item', /* Add New Display Title */ 'edit' => 'Edit', /* Edit Dialog */ 'edit_item' => 'Edit Portfolio Item', /* Edit Display Title */ 'new_item' => 'New Portfolio Item', /* New Display Title */ 'view_item' => 'View Portfolio Item', /* View Display Title */ 'search_items' => 'Search Portfolio Items', /* Search Custom Type Title */ 'not_found' => 'Nothing found in the Database.', /* This displays if there are no entries yet */ 'not_found_in_trash' => 'Nothing found in Trash', /* This displays if there is nothing in the trash */ 'parent_item_colon' => '' ), /* end of arrays */ 'description' => 'This is the portfolio custom post type', /* Custom Type Description */ 'public' => true, 'publicly_queryable' => true, 'exclude_from_search' => true, 'show_ui' => true, 'query_var' => true, 'menu_position' => 8, /* this is what order you want it to appear in on the left hand side menu */ 'menu_icon' => 'dashicons-format-image', /* the icon for the custom post type menu */ 'rewrite' => array( 'slug' => 'portfolio', 'with_front' => true ), /* you can specify its url slug */ 'has_archive' => 'portfolio', /* you can rename the slug here */ 'capability_type' => 'post', 'hierarchical' => true, /* the next one is important, it tells what's enabled in the post editor */ 'supports' => array( 'title', 'editor', 'thumbnail', ) ) /* end of options */ ); /* end of register post type */ } add_action( 'init', 'portfolio'); // Portfolio Taxonomy: 'Categories' register_taxonomy( 'portfolio_categories', array('portfolio'), array( 'labels' => array( 'name' => 'Categories', /* name of the custom taxonomy */ 'singular_name' => 'Category', /* single taxonomy name */ 'search_items' => 'Search Categories', /* search title for taxomony */ 'all_items' => 'All Categories', /* all title for taxonomies */ 'parent_item' => 'Parent Categories', /* parent title for taxonomy */ 'parent_item_colon' => 'Parent Categories:', /* parent taxonomy title */ 'edit_item' => 'Edit Category', /* edit custom taxonomy title */ 'update_item' => 'Update Category', /* update title for taxonomy */ 'add_new_item' => 'Add New Category', /* add new title for taxonomy */ 'new_item_name' => 'New Category', /* name title for taxonomy */ ), 'hierarchical' => true, 'show_ui' => true, 'query_var' => true, 'show_admin_column' => true, 'public' => true, 'rewrite' => array( 'slug' => 'portfolio-categories' ) ) ); register_taxonomy_for_object_type('portfolio_categories', 'portfolio'); // Flush your rewrite rules function volt_flush_rewrite_rules() { flush_rewrite_rules(); } add_action( 'after_switch_theme', 'volt_flush_rewrite_rules' ); ?> Then, my code for archive-portfolio.php is this: <?php get_header(); ?> <div id="content"> <div id="inner-content" class="wrap clearfix"> <div id="main" class="twelvecol first clearfix" role="main"> <h1 class="page-title" itemprop="headline"> <?php post_type_archive_title(); ?> </h1> <?php echo $cfs->get('intro_text_for_portfolio', 30); ?> <?php $terms = get_terms('portfolio_categories'); foreach ($terms as $term) { ?> <div class="portfolio-category threecol"> <a href="<?php echo get_term_link($term); ?>"> <img src="<?php echo z_taxonomy_image_url($term->term_id, 'portfolio-thumb'); ?>"> <?php echo '<h3>' . $term->name . '</h3>'; ?> </a> </div> <?php } ?> </div> </div> </div> <?php get_footer(); ?> This works great and shows the taxonomy images and links to the archive page however, despite it definitely calling the below template, it does now output any posts at all, even though they definitely exist and are set to published. Contents of taxonomy-portfolio_categories.php: <?php get_header(); ?> <div id="content"> <div id="inner-content" class="wrap clearfix"> <div id="main" class="twelvecol first clearfix" role="main"> <h1 class="page-title" itemprop="headline"> <?php single_cat_title(); ?> </h1> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <?php $image_id = get_post_thumbnail_id(); $image_url = wp_get_attachment_image_src($image_id); $image_url = $image_url[0]; ?> <?php the_title(); ?> <a href="<?php echo $image_url; ?>" class="portfolio-item"> <?php the_post_thumbnail('portfolio-thumb'); ?> </a> <?php endwhile; else : echo 'there is nothing here'; endif; ?> </div> </div> </div> <?php get_footer(); ?> Despite Googling everything I can, I can't seem to work out why it isn't working. It's getting to a point and then just not showing the posts. Everyone that's had this problem says it's because 'public' isn't set to true but mine is for both the cpt and tax. If anyone could shed any light on the subject, it would be very much appreciated. Many thanks, Jack
-
Using PHP cURL to download a file on click...
Hi, So I had a simple download script that allowed a visitor to download a sample video when clicking a link. The link was in this format: https://www.domain.com/videos/video1/download.php?https://www.domain.com/files/videos/video1.mp4 And here's the code from the download script: <?php $file = $_GET['file']; header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename='.basename($file)); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: public'); // For IE header('Pragma: public'); ob_clean(); flush(); readfile($file); exit; ?> Problem is, it worked in development but now the site's live with a new host, they don't allow using 'allow_url_fopen' as it poses a security risk. They've asked me to re-write the script using cURL instead but it's a bit beyond me. I've found this page that helps somewhat but all that code seems to do is output the contents of the video in text format as opposed to downloading it. I also don't know how to tie it in so that on the click of a link, it starts the download. Can anyone offer any help? Thanks, Jack
- Display CSS issue with EllevateZoom js
-
Play video on hover causing poster to not show
Thanks. I've actually posted this over on Stackoverflow too as I wasn't getting any traction here. Here's the post: http://stackoverflow.com/questions/20967179/play-html5-video-on-hover-causing-poster-to-not-show-video-delayed They managed to help a bit but the issue is that the posters (or the first frame of the video) doesn't show most of the time. Having the hover js effect in place actually helps as when you hover over the thumbnail it perks up thinks 'Ooh, I have to be playing a video' and starts playing it. Without this js, the video posters don't show at all, even with a hover.
-
Play video on hover causing poster to not show
Hi All, Ok, have a strange problem here that i'm hoping someone will be able to shed some light on. The site in question is here: http://tlt.voltronik.co.uk - Please scroll down to the Latest Clip / Most Popular Clips section. There are a few videos that when hovered over, should play. I've set the poster to be a relevant frame of the video so that they won't always use the first frame as it's not always the most appropriate. Here's the code i'm using to do this: var vid = document.getElementsByClassName("video-hover"); [].forEach.call(vid, function (item) { item.addEventListener('mouseover', hoverVideo, false); item.addEventListener('mouseout', hideVideo, false); }); function hoverVideo(e) { this.play(); } function hideVideo(e) { this.pause(); } The problem is (as you might have already discovered) is that sometimes the posters show and sometimes they don't. Sometimes they all load without fail and sometimes none of them do. Most of the time however, when they do show, you hover over a video and nothing happens. You have to move the mouse cursor off of the video, then re-hover over the video for the video to play. I attempted to compensate for the posters not showing by setting a background image of the poster to sit behind the video but this doesn't seem to show properly either. I don't think it's anything to do with the rgba background or the parallax style video playing behind because this behaviour is also visible on the 'Timelapse Clips' page too. Can anyone shed any light on why this might be happening? Thanks for any help in advance - it really is appreciated! Jack
-
Display CSS issue with EllevateZoom js
Hi All, I have a strange problem with some CSS in relation to the EllevateZoom jQuery plugin. You can see the problem on this page: http://tlt.voltronik.co.uk/downloads/canary-wharf-d/ When the 'Play' option is selected below the video, the user can watch the video and when the Zoom option is selected, the user can zoom into a still of the video. The problem is, when the play option is selected, the zoom window appears when hovering over the top left of the viewport. When the preview option is selected, the zoom window appears where it should (to the right of the image). I've narrowed down the issue to setting display: none; or display: block; to the div containing the image. This is necessary to show and hide the relevant div when the navigation option (play or zoom) is selected below. I however, cannot seem to fix it no matter what I try. Can anyone offer any help or solutions as to how to overcome this? Thanks for any help in advance, Jack
-
-
Recent Post - Mangles Theme
The only things that would be causing the post to be mangled is if there was any styling being applied to any of the elements in your code. This could be due to CSS or JS inserting styles. Try using the Web Inspector to hunt for styles on the a or img elements or the .ngg-singlepic or .ngg-center classes. If no luck, please post a link so we can have a look.
-
Exclude user role from get_users list
Hi All, So i'm trying to exclude a user role from the get_user list in WordPress. The problem i've having is that i'm already excluding the current user and a certain user ID from the list and I feel i'm getting lost in arrays. This is my code for storing the user list in a variable: $users = get_users(array('exclude' => array($current_user->ID, 15))); What i'd like to do is grab a list of user id's (or display names) and include them in the 'exclude' section above. I've tried a lot including this below but it doesn't work: $ex_staff = get_users(array('role' => 'disabled_users')); if (is_array($ex_staff)) { foreach ($ex_staff as $ex_staff_member) { $member = $ex_staff_member->display_name; $comma_separated = implode(",", $array); } } Can anyone offer a suggestion or point me in the right direction? Thanks for any help in advance.
- Sort WordPress categories by ID?
-
Sort WordPress categories by ID?
Hi All, So I have some custom PHP in WordPress that loops through a custom taxonomy, showing the title of the taxonomy and then its associated posts below it. My code looks like this: <?php // get all the categories from the 'press_cat' custom taxonomy $cats = get_terms('press_cat'); // loop through the categories foreach ($cats as $cat) { // setup the category ID $cat_id = $cat->term_id; // Make a header for the cateogry echo "<h2>".$cat->name."</h2>"; // create a custom wordpress query query_posts(array('post_type' => 'press','cat' => $cat->cat_id, 'press_cat' => $cat->name, 'orderby' => 'id')); // start the wordpress loop if (have_posts()) : while (have_posts()) : the_post(); ?> <?php print_post_title() ?><br /> <?php endwhile; endif; } ?> This is great and works well however, it's listing the categories in alphabetical order. I'd like to order them from newest to oldest (top to bottom) but as WordPress doesn't store creation dates for categories in the database, i've read that sorting them by their ID should produce the same effect. As the above code is fairly custom, Its not quite as simple as using wp_list_categories. Can someone offer any help on how I can add my requested feature to the above code? Many thanks for any help, advice or suggestions in advance. Jack
-
Help with adding and removing classes
Thanks, yup. It's looking good. Thanks for your help!
-
Help with adding and removing classes
If you're referring to the Isotope plugin then yes, i'm aware of it but it's a little to advanced for what I need in this particular situation.
-
-
Help with adding and removing classes
That's spot on thanks! It's for a filterable portfolio - i'm targeting the 'show' items with CSS and doing some nice fading animations using opacities and transitions.