Tag Info

New answers tagged

0

For displaying "Pending" post to the users you can add "post_status" parameter to get_post() or wp_query function like post_status (string / array) - use post status. Retrieves posts by Post Status. Default value is 'publish', but if the user is logged in, 'private' is added. And if the query is run in an admin context (administration area or AJAX call), ...


0

You can rewrite you .htaccess if you are familiar with this. Add the below line and try it: RewriteRule ^category/(.+)$ http://www.site.com/$1 [R=301,L]


0

If you go to Settings->Permalinks you should be able to set the tag/category base URL rules which should solve this problem. Or, use some sort of plugin to do what you want. This one came up first on Google: http://wordpress.org/plugins/custom-permalinks/


0

Your theme probably uses more than one menu - but which ones is visible depends on whether you are viewing the website on a big or a small screen. Check the source files and make sure the link is the same in both menus.


0

This is the default. WordPress will add markers before and after its rules and not touch anything else: # BEGIN WordPress # WP rules here … # END WordPress Just make sure to set your rules before the WordPress rules, because WordPress’ rewrite rules are rather greedy (they have to), so later rules will probably not apply.


0

I add another answer, to solve also the problem of linking. I've made another function to use with the 'is_page_template' way: //assume wpml as multilingual plugin function get_link_by_template($template,$check_lang = false){ global $wpdb; //if there's the need of adding lang vars on the URL $lang_join_string = (!$check_lang) ? "" : " left ...


0

Your code works to create links, and WordPress should make a valiant effort to find the correct post, but it doesn't get complete permalinks. To do that you will need to query the database for the post and construct a permalink if one is found. function transform_pseudo_anchor_wpse_101201($match) { global $wpdb; if (isset($match[1])) { $name = ...


0

Trying the add_filter option didn't actually work for me. The code gets quite ugly as the home_url function was impacting permalinks which have index.php and all my attempts to get it working failed. The best solution I came up with was to modify the Site Address (aka home_url) in General Settings to be http://domain.com/index.php. Then change the ...


1

You can filter home_url: add_filter( 'home_url', 'wpse102523_home_url' ); function wpse102523_home_url( $url ) { return $url . 'index.php/'; } Reference: Adam Brown's Filter Database


0

Use Page Links To plugin by Mark Jaquith. Edit top level page and in section Page Links To select An alternate URL and enter # as an URL.


0

I've found out that another answer could be to just use the is_page_template tag. Since I'm preatty sure that the NAME of the php template file that needs custom css and/or js will be the same through all the languages (both using the multisite way or things like WPML), I can say if(is_page_template('that-page.php') do this.. Simple and fast.


0

Thanks to @rofflox and @toscho for giving me the link. web.config file was not created as i was working on localhost as WAMP i.e Apache and it required when i shifted to production as it was running IIS. So i created a blank web.config file and added the following content. <rewrite> <rules> <rule name="Main Rule" ...


0

if you are referring to the 'posts page' as set under dashboard - settings - reading: <?php if( get_option( 'page_for_posts' ) ) { echo get_permalink( get_option( 'page_for_posts' ) ); } else { echo home_url(); } ?>


0

<?php echo home_url(); ?> <-- Set in Settings > General > WordPress address <?php echo site_url(); ?> <-- Set in Settings > General > Site address


0

The basic rewrite rules for pretty permalinks in WordPress look like this: # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress Note the RewriteRule. That part is ...


0

The query string format-- the "default" permalink-- should always work. For posts that is ?p=<post-id> for pages it is ?page=<page-id>, though ?p= will also work for pages (with the overhead or a redirect). Categories are ?cat=<cat-id>. Tags are ?tag=<tag-id>. There are many others.


1

get parameter for this is paged. Example: mydomain.tld?paged=2


1

The template tags the_permalink and the_title do not return values, they echo them. Use get_permalink and get_the_title instead. As an aside, the earlier are simply wrappers that echo the return of the latter. As another aside, yes, the naming is inconsistent. (And yes, that's annoying. At least to me.)


0

I used the following plugin lately: https://github.com/kasparsd/numeric-shortlinks it normally create post ID based shortlinks, like http://domain.com/123, but has an option for alpha-numeric shortlinks too, like the example in your question. The option can be activated like this: add_filter( 'numeric_shortlinks_bijection', '__return_true' );. Take a look at ...


0

bit.ly Offers URL redirection service with real-time link tracking. Sorry, I do not think it's possible and even if it was I do not understand why you need it.


0

I've found a working solution around JetPack, that I can be inspired from it, for future reference. Discussion about it: Support for sharing_permalink filter inconsistent Plugin implementing it: Jetpack shortlinks for sharing buttons Seems that this plugin does exactly what I want: Intercepts sharing buttons to use post's shortlink by adding a filter for ...


1

I very much doubt you can universally "trick" all plugins without touching at least some of some plugin code, but I think your best bet would be filters on the_permalink and post_link, and maybe pre_post_link. Even if you got that working it would be pretty "heavy". That is, a lot of processing happens before you get to interrupt things.


2

Go to Settings/Permalinks and add the static string to to the permalink structure: No need to touch the .htaccess. Update To make WordPress sending a hash # for its post permalinks you have to filter pre_post_link to make the structure '#%postname%' and post_link to remove trailing slashes: add_filter( 'pre_post_link', function( $permalink ){ ...


1

Try using the following for your rewrite rules: location / { try_files $uri $uri/ /index.php$is_args$args; } Using that schema, you can manually remove index.php from your Permalinks settings without breaking anything. Nginx will now check any URI for its existence as a file on the filesystem, and then a directory on the filesystem, and if neither ...


0

Just discovered that as of version 6.2 of Theme My Login the %username% variable is available for use in the Custom Links module. Therefore to add a link to the user's BuddyPress messages from the widget, the URL is http://yoursite.com/members/%username%/messages.


0

The problem ended up being that the wp_rewrite was not flushed on the push to the Heroku server. So, what I ended up doing was creating a file in the root directory with the following code: <?php global $wp_rewrite; $wp_rewrite->flush_rules(); ?> Then I added a deploy hook for heroku via command line heroku addons:add deployhooks:http ...


1

Spaces are invalid characters in URLs. Your links are broken, whether the posts exist or not and regardless of whether you want the spaces or not. And uppercase/lowercase can get you in trouble too. Some servers are case sensitive so if you have a permalink to http://somesite.com/hello-world a link like http://somesite.com/Hello-World might work or it ...


0

After many efforts I have solved it. But not completely what I want, had to compromise on one thing and passed some separators in between Url. Example: http://sitename.com/separator1/parentatx/childtax/separator2/postname/ And in order to avoid 404 errors in case of pagination and another custom taxonomy. I created some rewrite rules. Here is my code: ...


1

Question interested me, so I took a shot. Not tested, so recommend backing up the wp_posts table before running (though you should do so regardless!) As mentioned in the comments, don't forget to replace "domain.com" in the regular expression with your own. require 'wp-load.php'; // Only needed if *not* a plugin. function out_with_the_old( $match ) { ...


1

If you're getting Index of /blog Apache Server Port 80 instead of a 404 page, you might be having a folder called blog in on your server. Try deleting or renaming that folder if you're not using it. EDIT: Here is a related question: WP Page and Subdirectory with same name


0

Try resetting the permalink by clicking "Save Changes" in Settings > Permalinks in the admin page. If that doesn't work, read the documentation of your new theme to see how it wants to create blog page. For example, some theme require you set Blog page in Settings > Reading, while some theme require you change the page setting to use Blog template. So there ...


1

In a quick test, I was surprised to find that this works out of the box. That is, the canonical URI for a child post still has the parent in the path, but the child post works just as well without it (doesn't 404, doesn't redirect). As a result, it should just be a matter of filtering post_type_link to get this to work as you're asking! The following code ...


1

Whenever I create a plugin that needs permalinks enabled i check on the plugin activation and if its not set i display a message for the user: // Add Check if permalinks are set on plugin activation register_activation_hook( __FILE__, 'is_permalink_activate' ); function is_permalink_activate() { //add notice if user needs to enable permalinks if (! ...


0

I found the code. modify_permalinks('/%postname%/','',''); function modify_permalinks($permalink_structure, $category_base, $tag_base){ global $wp_rewrite; require_once(ABSPATH . 'wp-admin/includes/file.php'); require_once(ABSPATH . 'wp-admin/includes/misc.php'); # get paths $home_path = get_home_path(); $iis7_permalinks = ...


1

You'll need to add 301 redirects for the old URL to the new one. Your best bet is to do this via .htaccess, in your theme, or using a plugin like one of these: http://wordpress.org/plugins/simple-301-redirects/ http://wordpress.org/plugins/safe-redirect-manager/ Edit: Another option OPtion 2 would be to disregard the date in the URI altogether. You ...


0

When you create permalink structures like /article/%category%/%postname%/, it becomes very complicated when %category% is hierarchical. The problem WordPress runs into is knowing if after the second slash, the next part of the URL is a category or a post. For instance, in the url /article/parent/child/, is "child" a subcategory of "parent", or is it a post ...


1

Try to do something like this. <?php /* Plugin Name: My Custom Plugin Plugin URI: Description: Author: Version: 1.0 Author URI: */ /* Runs when plugin is activated */ register_activation_hook(__FILE__, 'mcp_install'); /* Runs on plugin deactivation*/ register_deactivation_hook( __FILE__, 'mcp_remove' ); function mcp_install() { //Make sure ...


0

Rewrite rules for custom post types are controlled by their registration arguments (see rewrite in register_post_type() ) and probably shouldn't be modified externally. Also note that flushing rewrite rules on every page load is extremely bad for performance. That should only be done when they change, such as on activation of your plugin.


0

do something like this: function setup_permalinks_by_default() { global $wp_rewrite; $wp_rewrite->set_permalink_structure('/%postname%/'); $wp_rewrite->flush_rules(); } add_action('after_switch_theme', 'setup_permalinks_by_default') but this - if i'm not mistaken - will not take care of creating the .htaccess file edit: missed the part ...


0

There isn't a clean way to do what you're asking. What you want is for WordPress to check to see if, for a given URL, there is a post with that slug, and if not, try to find a category with that slug. With the exception of pages, WordPress doesn't check to see if an opject (post, term) exists before "committing" to a matching rewrite rule. Therefore, when ...


0

For anyone interested, it was the SEOyoast plugin that caused the problem. I turned it off and on, than the page appeared again in the admin. After that I rest the settings for the page and it now works as expected and accepts its template.


0

This is very easy to do by adding custom rewrite rules. This should get you started: add_action( 'init', 'wpse_100386_rewrites' ); function wpse_100386_rewrites() { add_rewrite_rule( 'case-studies/room/([^/]+)/?', 'index.php?the_room=$matches[1]&post_type=the_case_study', 'top' ); add_rewrite_rule( 'videos/room/([^/]+)/?', ...


0

You can try this : 'rewrite' => array('slug' => 'products/%category%'), 'query_var' => true /* etc */ But I think it won't work as is if other links do not follow the same structure. So maybe you'll find a way here.


0

I'd be curious if someone can find a better solution to this. Here's what I came up with: function wpse_91821_flatten_page_paths( $wp ) { if ( false !== strpos( $wp->matched_query, 'pagename=' ) && isset( $wp->query_vars['pagename'] ) && $wp->query_vars['pagename'] && false === strpos( $wp->query_vars['pagename'], '/' ...


0

See my answer here: http://wordpress.stackexchange.com/a/100486/12324. The issue you're facing is that permastructs are adding multiple custom post types to the URL, which is confusing WordPress. You'll need to add your rewrite rules using add_rewrite_rule().


0

You could alter the query directly in your template or use the pre_get_posts action. Inside archive template: $taxonomies_to_match = array('the_room','the_system','the_style'); if(is_tax($taxonomies_to_match)) { global $wp_query; query_posts(array_merge($wp_query->query_vars,array('post_type' => 'the_case_study')); } Action Hook Method: ...


1

Though the above answer will work for the default setups in wordpress. If you are rewriting the slug names for your taxonomies then Jan Fabry's answer won't work. It just requires a modification. Also I would suggest to no do this as this will not fit with other plugins that you are might be using which does not know that you are using an index page for ...



Top 50 recent answers are included