sort CPT on Custom Taxonomy Archive page

I have created a custom post type called "al_product" and attached to it a custom taxonomy called "product_category".

In my archive-product_category.php I have this (relevant) code:

            if ( $  termchildren  ) {                 // we have kids...just show the terms.                            $  i=1;                 foreach ( $  termchildren as $  child ) {                     if ($  i % 2 == 0) {                         echo '<div class="tax-entry flex">';                     } else {                         echo '<div class="tax-entry flex" style="flex-direction: row-reverse;">';                     }                     ?>                         <figure class="wp-block-media-text__media">                             <?php if ( get_field('product_category_img', $  child) ) echo wp_get_attachment_image( get_field('product_category_img', $  child), 'full' ) ;?>                         </figure>                         <div style="flex:60% 0 0;" class="wp-block-media-text__content">                             <h2><?php echo $  child->name ;?></h2>                             <p>                                 <?php                                 if (get_field('short_description', $  child )){                                      echo get_field('short_description', $  child );                                 }else{                                     echo $  child->description;                                 }?>                             </p>                             <?php                             // Get (at most) 2 "product" posts in the child term.                             $  posts = get_posts( array(                                 'post_type'      => 'al_product',                                 'posts_per_page' => 2,                                 $  taxonomy_name   => $  child->slug,                             ) );                              // If there's exactly 1 post, use the post permalink.                             if ( 1 === count( $  posts ) ) : ?>                                 <a class="button" href="<?php the_permalink( $  posts[0] ); ?>">See this Product</a>                             <?php // Else, use the term link.                             else : ?>                                 <a class="button" href="<?php echo esc_url( get_term_link( $  child, $  taxonomy_name ) ); ?>">See this Series</a>                             <?php endif; ?>                          </div>                     </div> <!-- END FLEX -->                     <?php                     $  i++;                 }             } else {                  // no kids...show the products                 echo '<div class="productCategories grid">';                 while ( have_posts() ) : the_post();                     ?>                      <div class="product_cat">                         <a href="<?php the_permalink();?>">                             <?php the_post_thumbnail('small');?>                             <h2><?php the_title();?></h2>                             <?php                             $  subtitle = get_field('subtitle');                             if ( $  subtitle ) {                              echo '<h3 class="entry-subtitle">'.$  subtitle.'</h3>';                             }                             ?>                         </a>                         <?php //if (get_field('specs')['part_number']) echo '<span>'.get_field('specs')['part_number'].'</span>';?>                     </div>                  <?php                 endwhile;                 echo '</div>';             } 

The section I’m questioning is when there are no kids so we show products.

Currently this is returning the products correctly but sorting by title. I would like to sort by menu_order.

I added this to my functions.php:

add_action( 'pre_get_posts', 'rt_change_product_sort_order');  function rt_change_product_sort_order($  query){     if(get_query_var( 'product_category' )):        //Set the order ASC or DESC        $  query->set( 'order', 'DESC' );        //Set the orderby        $  query->set( 'orderby', 'menu_order' );     endif;     }; 

To no avail. I’ve also tried replacing the "If" statement with each of these:

if(is_post_type_archive( 'product_category' )): if(get_query_var( 'product_category' )): if(get_query_var( 'al_product' )): 

What am I missing here?

Conditional widget for a listing archive page

I am building a listing website (using ListingPro theme)

Inside the Listing Archive page I added some advertising widgets and I need to add conditions to it so that different content is displayed according to the location.

For example, the user chooses location A, the widget displays ads for A. The user chooses location B, displays for B, and so on.

I tried using the Widget options plugin but I don’t know how to set the logic condition here: Widget options

Using the conditional tags from here: https://codex.wordpress.org/Conditional_Tags

This is the website I’m working on: www.guiamercados.com

It has a search engine where you can choose a category and a location and then it shows a list of listings.

For example, if I search for the city of "Buenos Aires" it shows me the following link: https://guiamercados.com/?select=&lp_s_loc=1203&lp_s_tag=&lp_s_cat=&s=home&post_type=listing

As you can see from the link Buenos Aires has the ID 1203. How could I set the logic condition inside the widget so that it shows according to the ID of the location you are looking for?

Any ideas? Thanks in advance!

How to properly replicate and archive at once

I have a 300GB database that is growing around 5GB a day. It stores time-based data, and as such, I currently have around 60 days of data. My main database server has a 450 GB NVMe, so I want to get a secondary server that has expandable cheap storage for old data.

The main server only really needs the last 15 days of data. So anything older than 15 days of data I want to move off to the secondary database which has slower but cheap storage. I think standard backup or archiving isn’t viable because I want to query the data at any given moment (maybe ~100 queries a day).

I want to kill two birds one stone here and I thought if I setup replication to the secondary server and then somehow indicate the cleanup stored procedure which delete records older than 15 days doesn’t propagate deletes to the slave.

Is this possible and recommended? If not, what is the best way to accomplish archived the data but to another server and allow querying. I suspect partitioning all of my tables but not all of my tables are time-based so I would need some way to move the time-based partitioned data over along with any FKs needed for it

PS: I won’t be relying on the secondary server as a backup but rather my main replication. I would then do offsite backups of the secondary server periodically

WordPress Sub Category Archive, Show Extra Empty Page Number in Pagination

This my code for sub category archive page:

                        <?php $  my_query = new WP_Query( array( 'posts_per_page' => 12, 'post_type' => 'post', 'paged' => get_query_var( 'paged' ), 'post_status' => 'publish', 'category__and' => array( 2 ) ) ); ?>                                 <?php if ($  my_query->have_posts()) : ?>                         <?php while ($  my_query->have_posts()) : $  my_query->the_post(); ?>                          //Contents Here//                          <?php endwhile; ?><?php endif; ?>                                            <?php wp_reset_postdata(); ?> 

Now I have 1 empty extra page number in pagination of my archive page.

For example I have only 3 pages of contents by I can See a number 4 link in pagination numbers who open’s an empty page without any posts in there.

Can you help me please?

Custom Post Type Archive Page URL

I created a custom post type called provider, and currently I have a URL structure like so:

  1. .com/provider/abc
  2. .com/provider/xyz
  3. etc…

Now I would like to add some content in the provider page, mostly for SEO reasons. After having a look at how archive pages are working, I found out that it would be best to just change the URL of the archive page for provider. So the new URL would be .com/provider-archive/ while keeping the same URL for the provider already in the system, so they would remain:

  1. .com/provider/abc
  2. .com/provider/xyz
  3. etc…

This way, I would be able to create a regular page and give it the /provider/ URL.

I am trying to do so by changing the rewrite, adding in a slug to be provider-archive. After doing all of this, and creating a new page with the URL /provider/, when I try to access said URL I still see the archive.

This is how my custom post type is set up:

/**  * Register Provider Meta Box  */  add_action('init', 'cpt_provider'); function cpt_provider() {      $  labels = array(         'name'               => _x('Providers', 'post type general name', 'mebo-cpt'),         'singular_name'      => _x('Provider', 'post type singular name', 'mebo-cpt'),         'menu_name'          => _x('Providers', 'admin menu', 'mebo-cpt'),         'name_admin_bar'     => _x('Provider', 'add new on admin bar', 'mebo-cpt'),         'add_new'            => _x('Add New', 'book', 'mebo-cpt'),         'add_new_item'       => __('Add New Provider', 'mebo-cpt'),         'new_item'           => __('New Provider', 'mebo-cpt'),         'edit_item'          => __('Edit Provider', 'mebo-cpt'),         'view_item'          => __('View Provider', 'mebo-cpt'),         'all_items'          => __('All Providers', 'mebo-cpt'),         'search_items'       => __('Search Providers', 'mebo-cpt'),         'parent_item_colon'  => __('Parent Providers:', 'mebo-cpt'),         'not_found'          => __('No Providers found.', 'mebo-cpt'),         'not_found_in_trash' => __('No Providers found in Trash.', 'mebo-cpt')     );      $  args = array(         'labels'             => $  labels,         'description'        => __('Description.', 'mebo-cpt'),         'public'             => true,         'publicly_queryable' => true,         'show_ui'            => true,         'show_in_menu'       => true,         'query_var'          => true,         'capability_type'    => 'post',         'rewrite'           => array( 'slug' => 'provider-archive' ),         'hierarchical'       => true,         'menu_position'      => null,         'menu_icon'          => get_template_directory_uri() . '/img/icons/Gun-512.png',         'supports'           => array('title', 'editor')     );      register_post_type('provider', $  args); } 

Is there anything that I’m missing?

Filter custom post types in archive

I want to filter my custom posts (pump) with a custom filter form on it’s archive page (archive-pump.php).

So, I wrote the form markup:

<form method="GET">     <label>Series</label>     <?php         if( $  terms = get_terms( array( 'taxonomy' => 'series', 'orderby' => 'name' ) ) ) :             echo '<select name="series">';             foreach ( $  terms as $  term ) :                 echo '<option value="' . $  term->term_id . '">' . $  term->name . '</option>'; // ID of the category as the value of an option             endforeach;             echo '</select>';         endif;     ?>     <button type="submit">Apply filter</button> </form> 

And I have this to output my custom posts:

<?php if(have_posts()) : while(have_posts()) : the_post(); ?>     <?php the_title( '', '', true ); ?> <?php endwhile; endif; ?> 

When I open my page (localhost/project/pumps) it looks fine. But when I submit my form I’m getting an 404 page.

I maybe need an seperate query to fetch all the $ _GET data. But I’m not getting to the step because of the 404 error.

What am I doing wrong? Thank you!

How to apply custom filters for John The Ripper when cracking RAR3 archive password?

My problem is that I’m trying to crack RAR file with is encrypted with RAR3 encryption. Decided to try with John The Ripper. Here are clues I have from my friend.

  1. Max password length is 8
  2. Only capital letters or digits

And I need now filter to make John crack the password without trying to check small lowercase letters. On hashcat it’s easy to do but program do not support $ RAR3$ *1 type of hashes.

Use Custom Post Type archive page for the taxonomies term archive page

In my wordpress theme I created a new custom post type ‘books’ with 2 taxonomies (‘series’, ‘genres’). when I visit the archive of the cpt ‘books’ (site.com/books), I list all the books.

I added a custom frontend filter to get in this archive page books by taxonomy terms by passing an argument to the url with the name of the taxonomy and the terme (like this: site.com/books/?genres=action). Like a book browser.

But wordpress is by default creating the link for my taxonomies like this (site.com/genres/action/) and i want it to be "redirected" to the books post type with the taxonomy argument (site.com/books/?genres=action).

Is it possible to achieve that ? Thank you

Pagination (archive posts) getting out of hand – what to do from an SEO POV?

WordPress as many of us know creates an archive loop of old posts.

From an SEO POV, some of my categories are now at 100+ pages which is a lot of bloat…

Sure, I can set each of these paginated pages a canonical link but still, feels like it is a bit unnecessary for all these indexed pages that just contain a title and an excerpt (which is basically duplicate content..)

Is one approach to simply switch off archive loops or does Google ignore these archived pages?

Thanks