Tag Info

Hot answers tagged

2

The correct way to register a taxonomy is to wait for the action registered_post_type, because that’s the only way to know that your post type actually exists. This action is fired when a post type was registered. Core post types are registered twice for reasons. You have to wait for the second call, because the rewrite object is not available earlier. If ...


1

If you want an example of how to do the dropdown filtering using ajax, then if you factor out your taxonomy dropdown into your "functions.php": function my_dropdown_categories( $taxonomy, $current_selected = '', $include = null ) { // Get all terms of the chosen taxonomy $terms = get_terms($taxonomy, array('orderby' => 'name')); // our ...


1

This may be an alternative for you. The Advanced Custom Fields plug in has an Image Field, which allows images to be uploaded and selected. You can set the field to show on your Custom Post Type pages and also integrate a line of code into your template file. You can create as many image fields as needed. Learn more about the Image field here.


1

orderby does not accept the values ASC or DESC. These are acceptable values for the parameter order. Changing 'orderby' => 'rand' to 'order' => 'ASC' should be sufficient and should by rule work As already pointed out, if (have_posts() ): should be if ($the_query->have_posts() ): Apart from that little discrepancy, you code have to work It ...


1

You have inserted wrong thumb functions for large fancybox image URLs. <a href="<?php get_the_post_thumbnail(); ?>" class="project-img fancybox"></a> This get_the_post_thumbnail() returns an HTML image element but you need URL of image. Your first code should be like this. <?php $args = array( 'post_type' => 'portfolio' ); $loop = ...


1

I think you forgot to check if $the_query have posts. <?php $args = array( 'post_type' => 'testimonials', 'posts_per_page' => 1, 'orderby' => 'rand' ); $the_query = new WP_Query( $args ); ?> <?php if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ...


1

This might not answer your question, but you have a few issues with your code Do not use uppercase letters in function names, taxonomy names and custom post type names. Only use lowercase letters. Separate names with a underscore (_). Also, just a tip, never start these names with letters, or use a hyphen (-) to separate names Never use ...



Only top voted, non community-wiki answers of a minimum length are eligible