remove the else after the foreach:
add_action('parse_request', 'fid_parse_request');
function fid_parse_request($wp) {
// only process requests with "fid"
if (array_key_exists('fid', $wp->query_vars) && $wp->query_vars['fid'] != '') {
$args = array('post_type' => 'faculty_profile', 'meta_key' => 'wid', 'meta_value' => $wp->query_vars['fid'] , 'numberposts' => 1);
$redirect_to_post = get_posts($args);
if (!empty($redirect_to_post ) ) {
foreach ($redirect_to_post as $p) {
$link = get_permalink($p->ID);
wp_redirect( $link , 301 );
exit;
}
}
$url="http://cnn.com/";
wp_redirect( $url , 404 );
exit;
}else{
return $wp;
}
}
Related Posts:
- How do I Redirect a WordPress Page?
- How to disable Uncategorized category URL?
- Display most recent post in category instead of archive?
- How to after saving or publishing a post redirect back to the original page
- Phantom 302 status code when sending a POST requests on pages
- Redirect before post page
- Posts are being redirected to xampp home page
- Why is WordPress redirecting users to random posts after commenting?
- Plain permalinks not working!
- Relative redirects for posts, categories, products and product categories
- 301 (static page instead latest posts)
- Set static page/post from another blog on same network
- redirect to uploaded (wordpress) post after form submission from front-end
- When changing pages to posts, how do you set up 301 redirects for the page URLs?
- WordPress 302 Redirect to Random Product/Post/Page
- When WP_Query only returns 1 post, how do I automatically redirect to that post?
- add_rewrite_rule and template redirect not working
- Creating a redirect option for current page url
- How Do I Redirect WordPress Pages but not posts?
- Every time I try accessing a post it redirects me to the feed
- Redirect old Posts URL to new URL
- Redirect to custom post if custom archive page has just one result?
- How to 301 redirect from url with post id to permalink with post name (slug)?
- Submit New Post
- How to redirect if is post edit or publish page?
- how to redirect page after delete post inside a post page?
- issue in wordpress auto delete post and redirect to another 1
- Redirect posts to sub domain except pages
- 301 Redirecting posts without %postid% (just %post_name%) in permalink to ones with %post_name%_%postid%
- Post pages are redirecting to the 404 page in wordpress
- How to get Images included in Post
- Accessing the post content with WP_Query
- How do I use inline SVG in WordPress
- Add link on the top menu of the post table?
- Get the object ID by URL
- Add a special filter link to All Posts in admin
- Custom Post Status Posts viewable to the public
- Add an image box besides featured image?
- Use Cron to modify posts via sql
- Using Custom Posts with Metaboxes and Drop-downs
- Create pretty permalink for a post knowing the permalink structure
- How to change the title url on the edit post screen?
- jQuery inluclude still seems ncessary for script to work within post
- White Blank Page when Updating and Publishing Page/Post
- WP_Query Authors OR Categories
- get_the_content_feed with paginated posts
- How to create large page
- How to get rid of shortcodes in post content once and for all
- Why is querying posts messing up my pages?
- How can I find out what items a user has purchased? [closed]
- Print all the tags from a custom post type Please
- WordPress Loop – Next 3 Posts
- Redirect user to previous page after signup from custom form
- How to do set post permalinks using 6 digit random unique function?
- Get query parameters from external url and make a redirection
- Encountering “Wrong nonce. Action prohibitied.” when trying to alter User Role and unable to Post via WP Admin
- Prevent scheduled post being published if date/time is past current date/time
- Set Default Category to Username
- Issue where WP Featured Image will not display
- All Posts admin screen – show time underneath the ‘Date’?
- Display post category in foreach loop
- Single.php – Get Current Parent Category
- insert a warning message into post-new.php
- WP text editor change html markup
- preg_replace not removed “class”
- Is it possible to give the user the chance to select between two single template files to use in a post?
- Modifying the following code to displaying the title and the content of static page Posts page?
- 301 Redirection After Comment
- Insertion of a non-english string to database
- Adding a meta box to determine the sidebar [closed]
- https and wordpress breaks posts
- Date is wrong on ‘all posts’ page
- Is there a way to display others posts in my post?
- How do I disable the “by author” hyperlink on posts?
- How to call WordPress First Image Post or else Attached Image or Default
- Recent posts script mess up blog posts
- Regarding Posts
- How to Remove HTML Elements from Post Excerpt?
- How to optimize posts query in wordpress
- How do I redirect the browser to 404 page, if no posts are found in home page
- Featured Story Shortcode not outputting content
- Order by meta_key field in WordPress not meta_value field value
- How to remove a post from results by ID after query?
- Blog featured images disappeared on my homepage
- WP_Query extended with AJAX
- Manipulating images inside post content
- How to create frontend Post filter using meta query
- Point users to a specific url directory for some posts
- How to test if user is filtering post list in dashboard
- WordPress The Next Posts
- Post Format problem
- Add Image Before Posts Entry Title
- Some comment box wordpress in 1 post [closed]
- Adding The Post Template Dropdown to WP-Admin
- wordpress paginate, link to the right page
- Delete junk text from all the post using my sql command
- Separate categories parents, childs and grandchilds in dropdowns
- How to Do Custom Fields to Output a Definition List
- Using the_excerpt() some posts are truncated and some are not
- WordPress limit post that subscriber can create