Tag Info

New answers tagged

0

Finally figured out the answer. It is a mix of multiple different solutions I have found online but here it is! First step is to add this to your functions.php add_rewrite_rule( 'products/([^/]+)/([^/]+)/?', 'index.php?pmfg_product_categories=$matches[1]&products=$matches[2]', 'top' ); Secondly you will need this in your ...


1

Did you use it like that?? <a href="<?php get_permalink($id); ?>"><?php the_title($id); ?></a> for use to that foreach($ids as $id){ $link = get_permalink($id); $title = get_the_title($id); $links .= '<a href="'.$link.'">'.$title.'</a>'.'<br/>' ; //$links .= $link . ' <br>'; } get_permalink ...


0

The rewrite value actually comes before your post slug, so you need to visit localhost/wp/realizzazioni/{{POST_SLUG}} to view the post. If your new post's name is "Test" you should be able to view the post at localhost/wp/realizzazioni/test. Other tips: Make sure there isn't a page already using the realizzazioni slug. Finally, flush your permalinks by ...


1

There are 3 parts to making this work. Register the post type with correct rewrite slug and archive. We add the %category% rewrite tag to the slug so we can swap in the selected category. We also specify the archive name explicitly. I've omitted the rest of the register_post_type arguments here, the rest can be as-is in your own example. 'rewrite' => ...


1

$_GET refers literally to ?p=1 part of URL. With pretty permalink if it's empty then there is nothing to access. WordPress processed either case into query variables of WP_Query class. You should use get_query_var() to retrieve things like this, so in this specific case it would probably be get_query_var( 'p' ).


1

There might be better ways using filters or apache/nginx rewrites, but here are two ideas to consider from the admin UI point of view (untested): Idea 1: You can always visit /wp-admin/options-general.php change the whole the site url: but I don't think you're looking for that, since this will also change the home url. Idea 2: You might therefore ...


0

You just need the last part of your function where you switch to blog 1 and get the menu. function wp_multisite_nav_menu() { $args = array( 'menu' => 'Main Menu', 'theme_location' => 'main-nav' ); switch_to_blog( 1 ); echo wp_nav_menu( $args ); restore_current_blog(); }


2

Filter template_include, check if the current post is a product and load the product template. Example: add_filter( 'template_include', function( $template ) { if ( ! is_singular() or ! get_post_meta( get_the_ID(), 'price', true ) ) return $template; return locate_template( 'product-single.php' ); }); How exactly you determine if a post ...


0

Yes, the correct tag is %monthnum%. Here's a list of all the default rewrite tags, for reference.


1

There is nothing happening at one month, and nothing "locks" permalinks. There is no actual difference in the system, the only difference is in the initial multisite configuration interface. When you first define WP_ALLOW_MULTISITE to true, and visit the network screen, you get the initial setup menu which lets you set up the configuration. It looks much ...


0

That should only happen if, as you say, there is a post with the same unique permalink. Any in the trash will still have the same effect.


2

Your get_author_posts_url() seems wrong, it doesn't accept three parameters. Passing ID as first one should be sufficient to generate correct link, name argument is pretty redundant there.


3

Yes, this is the intended behaviour: page-{slug}.php - If the page slug is recent-news, WordPress will look to use page-recent-news.php So, simply use a different filename for your templates, like template-contact.php for example. You can find more info about this here: https://codex.wordpress.org/Template_Hierarchy


0

The excerpt automatically redirects to the single post page when clicked. I think the trouble you are having is is that [...] is not clickable, and you want to make it clickable. To do this you need to replace [...] with a custom Read More... link. You need to do something like this: function new_excerpt_more( $more ) { return ' <a ...


0

Goto Screen Options at the top right of your screen. Tick the checkbox for Slug. Type in the post title, then click in the textarea below and the permalink should appear a few seconds later.


0

I've not tried external rules, but you can achieve that with an internal rewrite and pagename: function wpd_page_rewrite(){ add_rewrite_rule( '^anothername/([^/]*)/?', 'index.php?pagename=$matches[1]', 'top' ); } add_action( 'init', 'wpd_page_rewrite' ); For parent/child pages you have to set pagename to the parent/child ...


1

I would set another page as the home page, add a custom template for the home page and put this in it: <?php wp_redirect( get_permalink( $id ), 301 ); exit; ?>


0

Not sure if you are asking how to do this, but it's a setting in Settings > Permalinks. You would select the Day and Name option. This should automatically format your Post articles in this format.


0

Milo got me on the right track. If anyone else happens to have this issue the code I used is: /** * Redirect broken attachment links to 404 */ function ww_404_broken_links(){ global $wp_query; if(is_attachment()){ $attachment_path = get_attached_file( get_the_ID() ); //If the file doesn't exist on the server show 404 ...


0

to add parameter to post url (permalink), i use like this: add_filter( 'post_type_link', 'append_query_string', 10, 2 ); function append_query_string( $url, $post ) { return $url.'?my_pid='.$post->ID; } output: http://yoursite.com/pagename?my_pid=12345678


0

Try updating your permalinks 3 times. Make sure you have set it correct. Also you should look into http://wordpress.org/plugins/super-cpt/ , makes it a lot easier to add custom post types.


0

So I was able to figure this out myself with the help of a great friend and php developer. I apologize some of the functionality i.e. CUSTOM::slugify() is custom but if necessary you can review my Div Starter theme to learn more about it. add_action( 'init', 'cc_rewrite_add_rewrites' ); function cc_rewrite_add_rewrites() { $specialties = ...


0

Have you tried refreshing the permalinks? Visit the permalinks page, and hit save - this SHOULD solve the issue if the CPT's are working properly in every other aspect.


0

The standard way to create the tag-archive page link is to ask it to WordPress with: echo get_tag_link($tag_id_or_tag_object) the function is smart enough to deal with id(s) or full tag objects like the ones returned by get_the_tags(). See here for more about the tag link: http://codex.wordpress.org/Function_Reference/get_tag_link


0

I have a development site as a subdomain of my main site, so I deal with this when I copy data from the live site to the development site to obtain a current version of the development site. First, visit http://codex.wordpress.org/Moving_WordPress#When_Your_Domain_Name_or_URLs_Change like cybnet recommended. Once you have changed the wp-config files as ...


1

Here's a simpler take. Only turn off the redirecting if none of the query_vars are present. In this way we get to keep the functionality, without the need to duplicate the logic already at redirect_canonical. add_filter('redirect_canonical', 'no_redirect_on_404', 10, 2); function no_redirect_on_404($redirect_url, $requested_url){ $id = ...


0

The permalink configuration in Wordpress backend is only for standard posts and pages. For CPT the default URL structure is http://example.com/cpt-identifier/post-slug. If you want a different URL structure for you CPT you will have to define and register your own rewrite rules. For example: add_action( 'init', 'register_posttype' ); function ...


0

GoDaddy is unique among hosts that I've seen in that the changes you make to .htaccess files don't take place immediately. They use some caching system for them in some manner. Turn on the permalinks and wait a day. It's worked for me in the past when I used to be hosted there.


-1

Move this one page into the "root" of pages - set it's parent to (no parent)


2

Add a rewrite rule and extra query vars to handle incoming requests, direct the rewrite rule to a single page post type, create a custom page template for that page, then do whatever querying you need using the query vars set by your rewrite rule.


0

What you should do is to create a CPT as a container for displaying your data. For each of the CPT "posts" store relevant meta data to is required to be able to get the data from the other DB, and create the per CPT themes files which will access the DB and display the data.


1

Use get_term_link() to get the correct URL for a taxonomy term archive. $list .= "\n\t\t" . '<li><a href="'. get_term_link( $tag ) .'">'.$name.'</a></li>';


0

The issue is that your script is doing a replace, but really what you want is to set the window location: Change your redirects from: window.location.replace(encodeURIComponent("http://www.url.com/?customposttype=postslug")) to window.location = "http://www.url.com/?customposttype=postslug"; And it should work properly.



Top 50 recent answers are included