Infinite Scroll appending Next Product Category Term pages

I discovered Infinite Scroll has an updateurl function: var nextURL; function updateNextURL( doc ) { nextURL = $( doc ).find(‘.tax-pages a.next’).attr(‘href’); } // get initial nextURL updateNextURL( document ); // init Infinite Scroll var $container = $(‘#main’).infiniteScroll({ // use function to set custom URLs path: function() { return nextURL; }, hideNav: “.tax-pages”, append: “#main ul.products”, … Read more

Store a value in global scope after init hook is fired

So after consulting on Facebook Advanced WordPress group, the advice was to create an object with setters and getters instead of using the declaring and getting variables in the global scope as shown in the code below: class MyPlugin { public $current_post_types; public function __construct() { add_filter(‘init’, array($this, ‘get_variables’)); } public function get_variables() { $this->current_post_types … Read more

How to change Custom Permalink for Taxonomy? (remove the slashes from term-slug)

I found the solution… add_filter( ‘term_link’, ‘remove_slash_taxonomy’, 10, 2 ); function remove_slash_taxonomy( $permalink, $term ) { if ($term->taxonomy == ‘nieruchomosc’) $permalink = str_replace(“https://wordpress.stackexchange.com/”.$term->slug.”https://wordpress.stackexchange.com/”, $term->slug, $permalink); return $permalink; }

How to prefix custom post type URL with custom post taxonomy term?

Ok, found the (a?) solution. “rewrite” => array( “slug” => “activity”, “with_front” => false ), and function my_injecter_agence_in_activite_url( $post_link, $id = 0 ) { $post = get_post( $id ); if ( $post->post_type == ‘activity’ || ‘publish’ == $post->post_status ) { $terms = wp_get_object_terms( $post->ID, ‘agence’ ); if ( $terms ) { $post_link = str_replace(“activity”, $terms[0]->slug.’/activite’, … Read more

In child theme, add CPT to custom taxonomy registered in parent theme

Ok, so after another hours of digging through the codex, I found a solution. Hope this helps anyone else who is runs into the same issue. I had to use the register_taxonomy_for_object_type function. And then I used the init hook. Here is the function that worked for me. function add_cpt_to_project_tax(){ register_taxonomy_for_object_type(‘project_category’, ‘external_project’); register_taxonomy_for_object_type(‘project_tag’, ‘external_project’); } … Read more