Double count view in archive.php
You fire setPostViews twice in ad.php via PHP setPostViews($adID); via JS with your ajax function again. Remove one, and you should be fine.
You fire setPostViews twice in ad.php via PHP setPostViews($adID); via JS with your ajax function again. Remove one, and you should be fine.
Custom query in archive.php with pagination nightmare
The correct way is latter one – correctly configure your CPT registration to have post type archive and use appropriate template file for it. However it gets tricker with your additional requirements. Exposing post type archives to be used in menus is significantly requested/explored topic, but I don’t think it made it into core yet. … Read more
I have to do similar things all the time. You are already using ACF, which is what I use, actually I use ACF5 Pro version now, but the same thing can be achieved using ACF4 and the Options Page add on. What I do is create an options page for each post type and set … Read more
I think the best way to do it is to create a custom template page and get the list of terms (or whatever you need) on that template. template-activities-taxonomy.php <?php /* Template Name: Activities Taxonomy */ get_header(); ?> <? $terms = get_terms( ‘activities’ ); if ( ! empty( $terms ) && ! is_wp_error( $terms ) … Read more
It’s not displaying, because there is ‘the_post()’ called after first ‘of ( have_posts() )’ (3rd line) This call makes the loop move to the second post. So if you do the proper loop afterwards, the first post has already been done
Looking at the source code for wp_get_archives(), there is a filter called getarchives_join which you can use to restrict wp_get_archives() to a specific category You also need to get the current category ID, which is easy, simply use get_queried_object_id() You can try something like this to display archives for the currently viewed category add_filter( ‘getarchives_join’, … Read more
Before I start again, I just want to reinforce the fact you should not run a custom query in place of the main query on your archive pages. Please see this post to learn when you should use a custom query and where not. I you do not switch back to the default loop, then … Read more
WordPress uses a hierarchy of templates (see the visual overview) which it checks for presence. In your case when showing a category archive it will check for presence the following files in this order and use the first one it finds: category-$slug.php (In your case probably category-news-events.php) category-$id.php category.php archive.php [paged.php] if paged index.php So … Read more
For this purpose there is get_term_link function (documentation). <a href=”https://wordpress.stackexchange.com/questions/199226/<?php echo get_term_link( 42 ,”product_cat’) ?>”>Fine Art … etc.</a> Product category is just WP taxonomy, so there is plenty of functions to work with. In this case you have to know your product category ID (taxonomy term ID, actually). When editing category, you will find it … Read more