php


Post tags in Custom Post Type not showing in archive with WPML in non-default language


I've done some searching over the last couple of hours and I couldn't find a solution that worked; so here goes nothing:
I have a custom post type which has 'taxonomies' => array('post_tag') attached to it. I can properly add tags to this custom post type's item and can even find those tagged items in my archive.php (/tags/{tagname}).
So far, so good.
But now I want my "translated to English" item to show its tags aswell (/en/tags/{a different tagname}) (I don't want copies of my tags, just new non-related tags for English.
However; this doesn't work! All tags I tagged in English items do not show up on my /en/tags/ page (not even if I leave out the /en/ part)
In my custom post type I've tried changing the has_archive key to a few things:
true
false
'has_archive' => icl_translate('wpml_custom', 'wpml_custom_case',
'case')
All to no avail.
In short: How can I get my English tags to work just as the Dutch(default lang) for my custom post type so they show up in my archive?
The registration of my post type
function case_post_type() {
$labels = array(
'name' => 'Cases',
'singular_name' => 'Case',
'add_new' => 'Toevoegen',
'add_new_item' => 'Nieuw case toevoegen',
'edit_item' => 'Case bewerken',
'new_item' => 'Nieuwe case',
'all_items' => 'Alle cases',
'view_item' => 'Bekijk case',
'search_items' => 'Zoek case',
'not_found' => 'Geen cases gevonden',
'not_found_in_trash' => 'Geen cases gevonden in de prullenbak',
'menu_name' => 'Cases'
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'exclude_from_search' => false,
'query_var' => true,
'rewrite' => array( 'slug' => 'case' ),
'capability_type' => 'page',
'has_archive' => false,
'hierarchical' => false,
'menu_position' => 8,
'supports' => array('title', 'editor', 'excerpt', 'thumbnail', 'page-attributes'),
'menu_icon' => 'dashicons-format-gallery',
'taxonomies' => array('post_tag')
);
register_post_type( 'case', $args );
}
add_action( 'init', 'case_post_type', 0 );
My Archive.php just has the_loop(). plain and simple.
I've fixed the issue! It wasn't that there were no records; I just tagged a lot of cases and blogs and thought the my archive.php would pick up both since they had the same tag. This wasn't the case.
So with a pre_get_posts function I can get both my cases and my posts on my archive page:
function wpa_cpt_tags( $query ) {
if ( $query->is_tag() && $query->is_main_query() ) {
$query->set( 'post_type', array( 'post', 'case' ) );
}
}
add_action( 'pre_get_posts', 'wpa_cpt_tags' );

Related Links

replace while loop with foreach
php remove forward slash from php URL
Show a list of members whose status = 0
How to arrange delete process in project
how to pass an array of data through cURL in php?
Mysql_num_row() expects parameter 1 to be resource
How to check duplicate and upload the new data when I use PHP to upload the CSV file into MySQL database
How to register aliased class as global class
MySQL - “Unexpected input field parameter in database query.”
MySQLi Prepared Statement UPDATE affects 0 rows, silent fail with error checking
How to insert text to a database in php
user authentication using sessions causes redirect loop
Empty rows in csv file
php script error debug
wordpress 404 error when trying to acess folder on root
How to assign a unique ID to a database object

Categories

HOME
list
keyboard
bots
add-on
windows-10
haproxy
command-prompt
dry
code-formatting
plaid
ios-simulator
yql
malware
lvm
gprs
migrate
nsstring
jquery-select2-4
feature-extraction
smartgwt
stimulsoft
squirrel-sql
sql-injection
distributed-computing
synthesis
scheduled-tasks
android-custom-view
unity-container
sybase-ase
ipa
cube
progid
nsmutablearray
quickcheck
jslint
plane
supertest
visual-format-language
simple-schema
http-basic-authentication
case-when
emacs25
allegro
scheduledexecutorservice
yui3
ipywidgets
maximize
gravatar
place
dsa
cfwheels
console.log
phonegap-facebook-plugin
adwords-apiv201402
mobile-country-code
squeezebox
box2dweb
redpitaya
typesafe-stack
smips
pbkdf2
jquery-transit
quickgraph
apportable
flv
cmath
story
word-frequency
fbml
sql-parametrized-query
photo-management
grails-validation
gaelyk
ixmldomdocument
raw-data
chronic

Resources

Encrypt Message