Tag Info

Hot answers tagged

5

It is okay that the URL changes to http://mysite.com/contact/#rocket, but you should change the way you are defining your anchor on the target page. Instead of using this method <a name="rocket"></a> <div> <h3>The Title</h3> <p>some text</p> </div> You should add an ID to the content you want to jump to ...


5

$_SERVER['REQUEST_URI'] will not be empty in WordPress, because it is filled in wp_fix_server_vars() (file wp-includes/load.php). This function is called in wp-settings.php before any plugin is loaded. So you can use it. But always escape the value. It is global and can be changed by any other code, so you cannot trust its value.


3

If you are looking for the post edit url for admin end and you have the post id (suppose $post_id) with you, then you can use the following code for getting the url. $post_url = admin_url( 'post.php?post=' . $post_id ) . '&action=edit';


3

Currently I can't offer a full answer to your question, but here as a starting point a (PHP 5.3+/closure) plugin that dumps the global WP_Rewrite object into the shutdown hook. <?php /* Plugin Name: Show WP_Rewrite Dump at the last hook (shutdown) */ add_action( 'shutdown', function() { var_dump( $GLOBALS['wp_rewrite'] ); } ); This doesn't take ...


2

Nothing just happens for "no apparent reason". Some new condition has caused this. Most likely a new plugin or update of an existing plugin. It is possible for a plugin or theme doing something crazy like flushing rewrite rules on every load could wipeout the existing rules. See this ticket for more info: ...


2

The answer by Milo above seems to potentially be a bit off the mark, because it doesn't result in http://skipology.com/category/ being an actual page, but instead it just redirects to another page. I don't know for sure so I'm just adding mine here as an alternative. If you are ok with a little bit of manual setup for this, this would be the simplest way to ...


2

Re: the comments above: Read http://codex.wordpress.org/Changing_The_Site_URL It says: There are four easy methods to change the Site URL manually. Any of these methods will work and perform much the same function. And the Codex outlines each one. The first one is the easiest; add these lines to wp-config.php with FTP or your hosting control panel ...


2

There are a number of template filters available to override template selection. For a single post you can use the single_template filter: function wpa_single_template( $template ) { if( isset( $_GET['template'] ) ) { $template = locate_template( $_GET['template'] . '.php', false ); } return $template; } add_filter( ...


2

From the WordPress Codex, this is how to enable permalinks in your blog. From your admin dashboard on the left side go to Settings -> Permalinks In the Settings → Permalinks panel (Options → Permalinks before WordPress 2.5), you can choose one of the "common" structures or enter your own in the "Custom structure" field using the structure tags. ...


2

Why? I think the reason why a) domain.com/123 is not redirected back to b) domain.com/123/post-slug with the /%post_id%/%postname%/ permalinks settings, is that the matched rule is: [matched_rule] => ([0-9]+)(/[0-9]+)?/?$ You can get that information from the global $wp object. There are other useful informations in $wpavailable after the wp ...


2

What about something like that? function wpse139657_orderby(){ if( isset($_GET['orderby']) ){ $order = $_GET['order'] or 'DESC'; set_query_var('orderby', 'meta_value_num'); set_query_var('meta_key', $_GET['orderby']); set_query_var('order', $order); } } add_filter('pre_get_posts','wpse139657_orderby'); In this way ...


2

By far the easiest fix is to edit wp-config.php to define two constants. (s)FTP into your site, or use a host supplied file manager, and add: define( 'WP_SITEURL', 'http://www.abc.com/folder' ); define( 'WP_HOME', 'http://www.abc.com/folder' ); Those will be used instead of the information in the database. That will get your site up and running again. ...


2

First, it is hard to believe that wp_redirect isn't working, below some (example) code how to use it: function wpse101952_redirect() { global $post; if( /*SOME CONDITIONAL LOGIC*/ ) { //examples: is_home() or is_single() or is_user_logged_in() or isset($_SESSION['some_var']) wp_redirect( /*SOME SPECIFIC URL*/ ); exit(); } } ...


2

This happens in redirect_canonical(). You can disable that function with: remove_action('template_redirect', 'redirect_canonical'); But be aware it does a lot more. Too much for my taste … So there might be side effects.


2

The asker solved the issue with $_SERVER["HTTP_REFERER"] but refused to post that as a real solution. Let me suggest something better, because the referer might be empty or full of malicious code. Never use that. First, we make sure, we get both arguments for that hook: add_filter( 'comment_post_redirect', 'wpse_97580_comment_redirect', 10, 2 ); Then we ...


2

In general circumstances, using URL parameters, you can list posts that belong to a specific category AND a custom taxonomy, like this: http://example.com/category/cars/?edition=usa Where, category is the Category base you are using for categories on your site (WordPress Dashboard > Settings > Permalinks > Category base); edition is the custom taxonomy's ...


2

You are doing everything right, double check the below code and make sure to go to Permalinks in your dashboard to flush the rewrite rules. From Wordpress Codex: Note: Visiting the Permalinks screen triggers a flush of rewrite rules. There is no need to save just to flush the rewrite rules. It will work, I tested it using the below code: Put the ...


1

The pattern you posted... www.mydomain.com/image.jpg('custom-thumb'); ... is a bit odd. That would be pretty tricky. You'd need a PHP handler to load the image and you'd need to tell the server (Apache, Nginx, IIS, Whatever) to parse that file ending as PHP. Something like this would be simpler: www.mydomain.com/image.php?size=custom-thumb You would ...


1

TimThumb (source code) is probably what you think you need, and probably good enough now, considering that it's been a while since it was last exploited. Like anything else, it comes with its own pros/cons (just google 'em). But you should know that once you get the hang of add_image_size and the_post_thumbnail functions you'll never have to go back. PS: ...


1

Always include http:// in your URLs. Change www.youtube.com in http://www.youtube.com/ or even better http://youtube.com/ If you forget the http:// then the data is being parsed like it is another page on your website rather than an external website, that's why you'll see 192.168.1.100/wordpress/www.youtube.com


1

The bulk of your question is fairly easy and has been covered here many times before. I also gave a talk at WordCamp Portland on the topic, which you can watch, download slides, code, etc. here. The last part of your question, On top of that I would like to create some additional pages which have a base of /marketing-lists i.e ...


1

Not sure if I'm understanding you correctly, but if you want to display a special of the day, depending on the day ... I have a rough representation of how you could go about doing so. Example: $current_day = date('N');// 1 (for Monday) through 7 (for Sunday) - daily/weekly //$current_day = date('j');// 1 to 31 - daily $specials = array( '', ...


1

I am using two strategies here... 1) is simple redirection to first child (using menu order) page-redirect.php <?php /* * Template Name: Redirector * Description: Empty Holder (redirect page) */ $rp = new WP_Query(array( 'post_parent' => get_the_id(), 'post_type' => 'page', 'order' => 'asc', ...


1

You can use add_rewrite_rule hooked to the init action, instead of using the generate_rewrite_rules filter (where it gets a bit low-level). But the actual problem with your rewrite rules is the regex in place. Here's what it'd look like: function wtnerd_edition_specific_categories() { add_rewrite_rule( ...


1

Take look at official Query vars. You will see two columns and by then you will get why category__in doesn't work with the URL query string. (basically, the private keywords works only if you specify them in wp_query or so...) About subpost, I am not a hundred percent sure, what it is. In the whole WP_Query it is mentioned only with attachments, take a ...


1

you can use paginate_links() from wordpress core API, its make more easily to paginate your custom query. And you dont need to make another query to get all users count. <?php $users_per_page = 10; // total no of author to display $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; if( (int)$paged === 1 ){ $offset = 0; } else { $offset = ...


1

It's not a post, just the mysite.com/what-we-do page. Refer to is_page(). <?php if ( is_page( 'what-we-do' ) ) { // We're on the What We Do page // do something } ?>


1

In you case I'd edited my wp-config.php, and just after if ( !defined('ABSPATH') ) define('ABSPATH', dirname(__FILE__) . '/'); I'd added $path = explode( basename( dirname(__FILE__) ), ABSPATH ); define( 'MYSITEROOTPATH', $path[0] ); after that, everywhere I need, I'd used // file.php is name of a file in root directory include( ...


1

You can use the 'current_screen' hook and get_permalink(): add_action( 'current_screen', function ( $screen ) { $url = get_permalink( $screen->id ); // ... } ); This hook receives a WP_Screen_Object with misc. information about the current admin screen the user is browsing. See ...


1

You should add your own custom query variable first: function add_search_store_query_var($vars) { $vars[] = 'search_store'; return $vars; } add_filter( 'query_vars', 'add_search_store_query_var'); And then add rewrite rule: function add_search_store_rewrite_rule() { add_rewrite_rule('stores/([^/]+)$', 'index.php?page_id=<YOUR SEARCH PAGE ...



Only top voted, non community-wiki answers of a minimum length are eligible