How to change ‘with_front” key from an existing custom post type?

You could try the newly register_post_type_args filter to adjust it. Here’s an untested example: /** * Set ‘with_front’ to false for the ‘experts’ post type. */ add_filter( ‘register_post_type_args’, function( $args, $post_type ) { if( ‘teachers’ === $post_type && is_array( $args ) ) $args[‘rewrite’][‘with_front’] = false; return $args; }, 99, 2 ); Updated with new info … Read more

paginate_links() don’t properly work in search.php?

I’m fairly certain this is answered elsewhere, but I’ll add it here again. I believe your issue lies here: ‘current’ => max( 1, get_query_var(‘paged’) ), Try this instead: global $wp_query; $wp_query->query_vars[‘paged’] > 1 ? $current = $wp_query->query_vars[‘paged’] : $current = 1; …then: ‘current’ => $current; Your ‘base’ may also be an issue. Instead of this: … Read more

Stop WordPress from reserving slugs for media items?

Thank you for the response everyone. I played around with macemmek’s solution and I think it led me to an even better solution: add_filter( ‘wp_unique_post_slug_is_bad_attachment_slug’, ‘__return_true’ ); That is all that is needed. This will automatically ‘skip’ the default assigned slug on any attachment. So an attachment that might normally get the slug “services” will … Read more

Combining Multiple Taxonomies in one URL

This rewrite rule should work (assuming “brand” and “type” are the taxonomy registered names): function custom_rewrite_rules() { add_rewrite_rule(‘^brand/(.*)/type/(.*)?’, ‘index.php?brand=$matches[1]&type=$matches[2]’, ‘top’); } add_action(‘init’, ‘custom_rewrite_rules’); Remember to flush the rewirte rules after saving this code in your site. Then you will need to hook in several places to fix things. For example, you may need to hook … Read more

How to filter to output of the get_permalink() function

Note that post_link filter is only for the post post type. For other post types these filters are available: post_type_link for custom post types page_link for page attachment_link for attachment The get_permalink()function is actually a wrapper for: get_post_permalink() get_attachement_link() get_page_link() in those cases. Here’s a way (untested) to create a custom wpse_link filter for all … Read more

Disable permalink on custom post type

<?php add_filter(‘get_sample_permalink_html’, ‘my_hide_permalinks’); function my_hide_permalinks($in){ global $post; if($post->post_type == ‘my_post_type’) $out = preg_replace(‘~<div id=”edit-slug-box”.*</div>~Ui’, ”, $in); return $out; } This will remove: Permalink itself View Post button Get Shortlink button If you want to remove permalink only, replace the line containing preg_replace with $out = preg_replace(‘~<span id=”sample-permalink”.*</span>~Ui’, ”, $in); UPDATE: get_sample_permalink_html has changed in version … Read more

How to use relative links on my pages?

$my_url=”my/relative/url.php”; echo site_url($my_url); site_url() when used by itself will return the absolute path to your blog. But, if you add an argument to it, as per my example above, it will prepend the absolute path to your path. Just make sure your URL doesn’t contain a leading slash (eg: /this/may/not/work). Finally, if you happen to … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)