Regular expressions (abbreviated regex) are terms that define a search pattern to focus on a specific part of a string for a specific purpose (e.g. to find/replace a word).

learn more… | top users | synonyms

0
votes
2answers
35 views

How to handle a post before publishing?

I want to do a regex match to each post before it gets published, and if the regex fails to match, delete the post entirely, what hook should I use?
0
votes
2answers
298 views

How to Create a Mod_Rewrite/Regex Rule to Redirect Requests old URLs to Their Updated Link Structure

Here goes... How would I create a mod_rewrite rule to that will redirect a variety of possible URL requests to their updated URL counter parts. We are migrating and old site to a CMS with a ...
2
votes
1answer
107 views

Regex in add_rewrite_tag not accepting OR operators?

I am trying to add a custom field to the post permalinks by using a combo of add_rewrite_tag and applying a post_link filter. What I am aiming for is something like this: ...
1
vote
1answer
132 views

Processing shortcodes in groups (separated by line breaks)?

The Project I'm working on a plugin to resize and embed rows of images using shortcodes that will be converted into <img> tags. In most cases there will be multiple images per row, and the ...
0
votes
1answer
36 views

regEx wp core file

I have an issue with the way WordPress handles creating a page anchor. The page anchor button is already defined in the WordPress TinyMCE code.. and can be added using either the Ultimate Tinymce or ...
0
votes
1answer
138 views

Rewrite Rule & Regex - Extract 'cat-name' and 'page-number' from http://domain.com/custom-post-type/category/cat-name/page/page-number

I have an URL formatted so: http://domain.com/custom-post-type/category/cat-name/page/page-number I need to extract: cat-name and page-number So that in my functions.php, I can create the custom ...
0
votes
1answer
123 views

Avoid too long words in a post title, post content or comment but only if its not a url

I want to prevent users from posting things like "aaaadfgdfgsdfgdaaaadsfgsdfgaaasdfgdfaaadfgsdfgaaaaaaaajahkjhkahkkjkjhaa..." which would not only be annoying but would certainly break the content div ...
1
vote
0answers
75 views

Regex to turn embedded images in to attachments

I've got a blog that has all images embedded in each post rather than a thumbnail linking to an attachment page which is what I'd like. I understand from this question that no plugin (like Regenerate ...
1
vote
0answers
99 views

What add_rewrite_tag()'s RegEx matches against?

I'm trying to figure out wether I can specify the position of the string to match (i.e. immediately after the domain) to reduce the chances of matching something else, but I don't even know what the ...
1
vote
0answers
152 views

Struggling with add_rewrite_rule

I've read this: Wordpress redirection to get url friendly That led me to this: 1) wp.tutsplus.com/tutorials/creative-coding/the-rewrite-api-the-basics/ 2) ...
0
votes
0answers
17 views

Add custom dynamic string to permalink structure wordpress

I am adding dynamic string to permalink but the problem is all the pages which runs from page.php goes to 404 whereas the detail page of the post is working fine. Code: add_filter('post_link', ...
0
votes
0answers
32 views

Add class to all parent elements inside the_content

Is there a way to add a class to all parent elements inside the_content? My problem is I'm using this kind of css selector: .post_content>* {margin-bottom:10px;} This is to due with mostly ...
0
votes
0answers
60 views

Customizing Walker_Nav_Menu - Trunicating spaces

I've just started learning to code WP themes pretty much from scratch and I'm trying to figure out how to pass a variable thru a customized Walker_Nav_Menu but without any ascii spaces. The goal is ...
0
votes
0answers
45 views

Rewrite rule for custom parameter

I'm stuck with rewrite rules regex. I have this kind of link: http://www.xyz.com/page-1_b/page-3_d/page-0_a/box-page-3_d I need to add rewrite rule for this link so that it extracts what's after ...
0
votes
0answers
47 views

how to prevent words inside image tags from being update in a sql query via php

I need to update certain words inside wp_posts table (1032 posts in a specific time range) but I would like to exclude some words when they are inside tags like so: <img ...