New answers tagged

0

function gp_remove_cpt_slug( $post_link, $post ) { if ( 'race' === $post->post_type && 'publish' === $post->post_status ) { $post_link = str_replace( '/' . $post->post_type . '/', '/', $post_link ); } return $post_link; } add_filter( 'post_type_link', 'gp_remove_cpt_slug', 10, 2 ); At this point, ...


1

The problem in your code is the lack of proper rules. You add 'rewrite' => 'CPT/%states%' in register_post_type() arguments. This causes that the rules generated for pathologists post type begins with pathologists/%states%/ and the address pathologists/alabama/ (pathologists/{term}/) will not be matched. More importantly, all posts from the custom ...


0

Function get_the_category() returns array, that is why the condition $postcat->slug == 'section' is always false. In its current form, your filter can change links to posts that do not have the section category. You should change the function to check the post for which get_permalink() was called, instead of checking the global $post. add_filter( '...


0

Prefix for post type post Here you will find how to add prefix only for post type "post". In the same way, you can add a prefix for the category. Suitable filter hooks are: category_rewrite_rules, pre_term_link. add_filter( 'pre_term_link', 'se342399_pre_term_link', 20, 2 ); add_filter( 'category_rewrite_rules', 'se342399_category_rewrite_rules', 20 ); ...


-2

I made this by jQuery: $('.sidebar-list li a').filter(function(){ return this.href === location.href; }).addClass('active');


1

You can just type it in, no need to do anything special.


0

Welcome to WP StackExchange! You may want to try something like this, which uses the same rewrite setting as your register CPT: $args = array( 'rewrite' => array('slug' => 'events/ecat', 'with_front' => false) ); register_taxonomy( 'ecat', array( 'events' ), $args ); Sources: https://cnpagency.com/blog/the-right-way-to-do-wordpress-...


1

The get_attached_file() function returns the path to a file based on the attachment ID: $FeaturedImage = get_attached_file( get_post_thumbnail_id() ); Getting the path to a specific size is more complicated. WordPress stores the filename for resized versions of the images in as attachment metadata, that can be retrieved with wp_get_attachment_metadata(). ...


0

To get the URL like example.tld/portfolio/PORTFOLIO-CATEGORY-NAME/PORTFOLIO-NAME/ do the following. Change rewrite for the custom post type to 'rewrite' => array( 'slug' => 'portfolio/%portfolio-categorie%', 'with_front' => false ), Change rewrite for the custom taxonomy to 'rewrite' => array( 'with_front' => false ), ...


0

As @WebElaine commented on this question I tried the following code which worked for me. First, remove the slug from the permalink function na_remove_slug( $post_link, $post, $leavename ) { if ( 'services' != $post->post_type || 'publish' != $post->post_status ) { return $post_link; } $post_link = str_replace( '/' . $post->post_type ....


2

I think, there are two things to be resolved: 1) You need that posts (and other post types) also followed that command, so use both: add_filter( 'post_link', 'remove_parent_category', 10, 3 ); add_filter( 'post_type_link', 'remove_parent_category', 10, 3 ); 2) but then categories also need to have changed url, so use: add_filter( 'category_link', '...


0

Alternatively you can use my plugin and adjust the product permalinks directly from Wordpress admin dashboard. Firstly, you need to install Permalink Manager Lite from Wordpress Plugin Directory. Then you need to go to "Tools -> Permalink Manager -> Permastructures" admin page and scroll down to "Products". Now, you should replace the default permalink ...


0

You need to put this code into your product single page before get_header() function start. <?php global $wp; if( isset($_SERVER['QUERY_STRING']) && isset($_GET['order']) ){ $url = home_url( $wp->request . '/order/' ); wp_safe_redirect( $url ); exit; } ?>


0

May be the main reason of this issue is that the WordPress finds that this URLs already assign to any post which exists in database. so You have to check permalinks of the every pages/post or attachments are not using that permalink. It could be in publish, drafts or trash as well. or you can find in wp_posts table in database from phpmyadmin. you can ...


0

Maybe your .htaccess file is not writable if you are using debian or Linux based system aur Mac base system there are must be chances off the permission issue of the .htaccess file. First you need to check that that file is writable or not why WordPress? Because wordpress changes active .htaccess by own if you change any permalink settings wordpress ...


2

WordPress sites usually use body_class(), which adds CSS classes to the <body> tag. If you inspect the body element itself, most sites will show you something like <body class="page-template page-template-tpl-events page-template-tpl-events-php page page-id-1168 page-parent page-child parent-pageid-378"> You can tell from these classes that ...


1

Go into the wp-options table. Change the URL of your site in two places to https://www.example.com . Or go into the Admin, Settings, General, and fix the URL there. (The setting on that screen reads the value from the wp-options table.) Make sure there are no URL settings in the wp-config.php file. Any setting in wp-config.php for the URL will override the ...


Top 50 recent answers are included