x500.net
Forum Replies Created
-
Please provide a link to the code placed in WP.
Forum: Fixing WordPress
In reply to: Search entire site for URL and replace with a different URL?You need to bind the function to a particular filter that way:
add_filter('content_save_pre', 'mySearchAndReplace');
Place it just below the function.
You need to go through the WordPress filter list to find one responsible for filtering section you’re after.
Forum: Fixing WordPress
In reply to: Search entire site for URL and replace with a different URL?Yes, you need to apply filter to every section you want to replace string within.
Alternatively, you can preg_replace the entire html sent to the browser, but it’s not recommended if you care about performance at all.Forum: Fixing WordPress
In reply to: Search entire site for URL and replace with a different URL?function mySearchAndReplace($content) { $str='https://www.example.com/login'; $replacement='https://www.example.com/login?redirect_to=https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $content = preg_replace( '@' . preg_quote($str,'@') . '@', $replacement, $content ); return $content; }
To test the function you can do:
$content='My post content with the https://www.example.com/login string included'; echo mySearchAndReplace($content);
You’ll need to add filter that will use the function.
If you want to apply filter on a post content when it’s saved, use content_save_pre filter.
If you prefer not to manipulate any DB entries but just want to replace the sring before it’s printed to the screen, the_content filter may come in handy.More about WordPress filters here
in your functions.php file add
add_filter('content_save_pre', 'mySearchAndReplace');
Forum: Fixing WordPress
In reply to: Import posts to a New Post TypeIf you want to change all posts to different post type, you can try sql:
UPDATE wp_posts SET post_type="my_new_post_type" where post_type="post";
Please bare in mind that it’ll change all posts in the database with post_type set to post.
Forum: Fixing WordPress
In reply to: Where is add_action() for get_header is defined…?add_action is a global function, read more here
Forum: Fixing WordPress
In reply to: Search entire site for URL and replace with a different URL?Something like this plugin?
Forum: Fixing WordPress
In reply to: video shortcode autoplay and player size in WP3.6wp_video_shortcode takes more arguments from what I can see here
$args=[ 'autoplay' => true ] wp_video_shortcode($args)
paste the category template code, the if (have_posts()) part up to endif;
Forum: Fixing WordPress
In reply to: How to change Image Link For All Images,If it’s an image inserted into post content, click on the Add Media button above the post content, select/upload image, then from the right-hand side panel from ATTACHMENT DISPLAY SETTINGS section (scroll down) select ‘Link To’ -> Custom Url and past url in the box displayed.
Forum: Fixing WordPress
In reply to: custom email recipient in comments notification e-mailWordPress Codex – comment_post
You can try this:
add_action('comment_post', 'notify_author_of_reply', 10, 2); function notify_author_of_reply($comment_id, $approved){ if($approved){ $comment = get_comment($comment_id); if($comment->comment_parent){ $parent_comment = get_comment($comment->comment_parent); wp_mail($parent_comment->comment_author_email, 'Hello', 'Dude you got a reply...'); } } }
source: https://wordpress.stackexchange.com/a/36590
alternatively, you may be interested in this plugin
Forum: Fixing WordPress
In reply to: Jump to page anchor from any pageWhat are you trying to achieve?
Dynamic creation of links on a posts page or a static reference to home page with navigation to its sections?Forum: Fixing WordPress
In reply to: Jump to page anchor from any pagetry with no http protocol declaration and make sure the url starts with /
/#service /#section2 /#section3
Forum: Fixing WordPress
In reply to: Auto adding paragraphs to custom fields with 'wpautop'?<?php // so you declare a new variable here called $myLongDescription // then assign to it whatever the get_post_meta function returns $myLongDescription = get_post_meta($post ->ID, 'long-desc',true); ?> <p id="long-desc"> // and here is the wpautop formatting the string <?php echo wpautop( $myLongDescription, false ); ?> </p>
Forum: Fixing WordPress
In reply to: Index.php appears twice in URLCan you find paginate_links function in index.php or category.php file?