PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, February 8, 2022

[FIXED] Wordpress: How to redirect a post to an another post?

 February 08, 2022     php, redirect, wordpress     No comments   

Issue

I have searched a lot, and only thing i found is wp_redirect(). To use that function, I need to edit the files in the site. But i want to use only one file to communicate with my wordpress site. So, is there any other way to redirect a post from an additional php file like this:

redirect_post_to_link($post_id, $link);

I have tried (the first method that comes to mind) updating the post content to <meta http-equiv="refresh" content="0;URL=https://www.examplewpsite.com/postblabla"> with

include("wp-load.php")
$post = get_post( $post_id );
$post->post_content = $redirect_code
$update_output = wp_update_post( $post );
if($update_output != 0){ // ...code continues...

but it doesn't actually update the post, when you visit the post you get blank content.

sorry if i asked a incorrect question.


Solution

I just found how to solve this. removing filter during update progress by kses_remove_filters() makes me update the content whatever i want.



Answered By - aphelios
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing