Don't replace “|” with “(empty)” when generating slugs from title?Prevent Wordpress from abbreviating-long-slugs…-in-the-adminRegenerate Slugs From Title of PostsWhy ids in urls don't work but slugs do?Stop WordPress from reserving slugs for media items?Wordpress not adding -2 to slugs when saving post as draftReplace Wordpress %postname% suffix with %postid%?How to prevent Wordpress from abbreviating long slugs?Remove slugs from custom posts typeWhy don't WordPress post slugs allow accents?Duplicate category slugs from pages and posts

How to laser-level close to a surface

Was Tyrion always a poor strategist?

Driving a school bus in the USA

Why using a variable as index of a list-item does not retrieve that item with clist_item:Nn?

Why does the U.S military use mercenaries?

Shortest amud or daf in Shas?

How can I monitor the bulk API limit?

Told to apply for UK visa before other visas

Prints each letter of a string in different colors. C#

How to customize the pie chart background in PowerPoint?

Divisor Rich and Poor Numbers

FIFO data structure in pure C

Combining two Lorentz boosts

Failing students when it might cause them economic ruin

Using `printf` to print variable containing `%` percent sign results in "bash: printf: `p': invalid format character"

How come Arya Stark wasn't hurt by this in Game of Thrones Season 8 Episode 5?

Can I modify the report menu?

Large dominating sets in tournaments

Does a windmilling propeller create more drag than a stopped propeller in an engine out scenario

Is it standard to have the first week's pay indefinitely withheld?

Parse a C++14 integer literal

How was the blinking terminal cursor invented?

What would be the game balance implications for using the Gygax method for applying falling damage?

Why would company (decision makers) wait for someone to retire, rather than lay them off, when their role is no longer needed?



Don't replace “|” with “(empty)” when generating slugs from title?


Prevent Wordpress from abbreviating-long-slugs…-in-the-adminRegenerate Slugs From Title of PostsWhy ids in urls don't work but slugs do?Stop WordPress from reserving slugs for media items?Wordpress not adding -2 to slugs when saving post as draftReplace Wordpress %postname% suffix with %postid%?How to prevent Wordpress from abbreviating long slugs?Remove slugs from custom posts typeWhy don't WordPress post slugs allow accents?Duplicate category slugs from pages and posts






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I work for an architecture company and our project names mostly go like this: house|something, bridge|somewhere, building|whatever.
Now, when I want to add a new "project" named like that, Wordpress automatically converts it to housesomething, bridgesomewhere and puts that as the slug. I'd much prefer to keep some kind of separator, e.g. house-something, bridge-somewhere is what I want.



So, how to make WordPress convert "|" to "-" and not "(empty)"?
I'm obviously tired of doing that manually all the time.



It seems to me that it's very simple to do - takes just a simple search and replace kind of thing - if one knows where to look (in the WP core or wherever), but I haven't the slightest idea where to look, or what code to execute.










share|improve this question









New contributor



Marg9 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

























    1















    I work for an architecture company and our project names mostly go like this: house|something, bridge|somewhere, building|whatever.
    Now, when I want to add a new "project" named like that, Wordpress automatically converts it to housesomething, bridgesomewhere and puts that as the slug. I'd much prefer to keep some kind of separator, e.g. house-something, bridge-somewhere is what I want.



    So, how to make WordPress convert "|" to "-" and not "(empty)"?
    I'm obviously tired of doing that manually all the time.



    It seems to me that it's very simple to do - takes just a simple search and replace kind of thing - if one knows where to look (in the WP core or wherever), but I haven't the slightest idea where to look, or what code to execute.










    share|improve this question









    New contributor



    Marg9 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.





















      1












      1








      1


      1






      I work for an architecture company and our project names mostly go like this: house|something, bridge|somewhere, building|whatever.
      Now, when I want to add a new "project" named like that, Wordpress automatically converts it to housesomething, bridgesomewhere and puts that as the slug. I'd much prefer to keep some kind of separator, e.g. house-something, bridge-somewhere is what I want.



      So, how to make WordPress convert "|" to "-" and not "(empty)"?
      I'm obviously tired of doing that manually all the time.



      It seems to me that it's very simple to do - takes just a simple search and replace kind of thing - if one knows where to look (in the WP core or wherever), but I haven't the slightest idea where to look, or what code to execute.










      share|improve this question









      New contributor



      Marg9 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      I work for an architecture company and our project names mostly go like this: house|something, bridge|somewhere, building|whatever.
      Now, when I want to add a new "project" named like that, Wordpress automatically converts it to housesomething, bridgesomewhere and puts that as the slug. I'd much prefer to keep some kind of separator, e.g. house-something, bridge-somewhere is what I want.



      So, how to make WordPress convert "|" to "-" and not "(empty)"?
      I'm obviously tired of doing that manually all the time.



      It seems to me that it's very simple to do - takes just a simple search and replace kind of thing - if one knows where to look (in the WP core or wherever), but I haven't the slightest idea where to look, or what code to execute.







      permalinks slug






      share|improve this question









      New contributor



      Marg9 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.










      share|improve this question









      New contributor



      Marg9 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.








      share|improve this question




      share|improve this question








      edited 5 hours ago









      cjbj

      11.3k103067




      11.3k103067






      New contributor



      Marg9 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.








      asked 5 hours ago









      Marg9Marg9

      62




      62




      New contributor



      Marg9 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




      New contributor




      Marg9 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















          2 Answers
          2






          active

          oldest

          votes


















          3














          When WordPress inserts a post, it runs the title through a filter called sanitize_title to get the slug. By default there is a function called santize_title_with_dashes attached to this filter with priority 10. This function simply strips out the |. If it is surrounded by spaces those spaces will be converted to hyphens.



          So your task is to run a filter on the same hook before (say, priority 9) the default one and replace the | with - before it gets stripped away. Like this:



          add_filter('sanitize_title','wpse338050_replace_bar',9,3);
          function wpse338050_replace_bar ($title,$raw_title,$context)
          str_replace('


          Beware I didn't test this. Some debugging may be necessary.






          share|improve this answer
































            0














            If you put spaces in between the words and the separator | the permalink will automatically include dashes between the words. For instance try this as your post title:



            house | something, bridge | somewhere


            That results in the slug:



            house-something-bridge-somewhere





            share|improve this answer























              Your Answer








              StackExchange.ready(function()
              var channelOptions =
              tags: "".split(" "),
              id: "110"
              ;
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function()
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled)
              StackExchange.using("snippets", function()
              createEditor();
              );

              else
              createEditor();

              );

              function createEditor()
              StackExchange.prepareEditor(
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: false,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: null,
              bindNavPrevention: true,
              postfix: "",
              imageUploader:
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              ,
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              );



              );






              Marg9 is a new contributor. Be nice, and check out our Code of Conduct.









              draft saved

              draft discarded


















              StackExchange.ready(
              function ()
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fwordpress.stackexchange.com%2fquestions%2f338050%2fdont-replace-with-empty-when-generating-slugs-from-title%23new-answer', 'question_page');

              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              3














              When WordPress inserts a post, it runs the title through a filter called sanitize_title to get the slug. By default there is a function called santize_title_with_dashes attached to this filter with priority 10. This function simply strips out the |. If it is surrounded by spaces those spaces will be converted to hyphens.



              So your task is to run a filter on the same hook before (say, priority 9) the default one and replace the | with - before it gets stripped away. Like this:



              add_filter('sanitize_title','wpse338050_replace_bar',9,3);
              function wpse338050_replace_bar ($title,$raw_title,$context)
              str_replace('


              Beware I didn't test this. Some debugging may be necessary.






              share|improve this answer





























                3














                When WordPress inserts a post, it runs the title through a filter called sanitize_title to get the slug. By default there is a function called santize_title_with_dashes attached to this filter with priority 10. This function simply strips out the |. If it is surrounded by spaces those spaces will be converted to hyphens.



                So your task is to run a filter on the same hook before (say, priority 9) the default one and replace the | with - before it gets stripped away. Like this:



                add_filter('sanitize_title','wpse338050_replace_bar',9,3);
                function wpse338050_replace_bar ($title,$raw_title,$context)
                str_replace('


                Beware I didn't test this. Some debugging may be necessary.






                share|improve this answer



























                  3












                  3








                  3







                  When WordPress inserts a post, it runs the title through a filter called sanitize_title to get the slug. By default there is a function called santize_title_with_dashes attached to this filter with priority 10. This function simply strips out the |. If it is surrounded by spaces those spaces will be converted to hyphens.



                  So your task is to run a filter on the same hook before (say, priority 9) the default one and replace the | with - before it gets stripped away. Like this:



                  add_filter('sanitize_title','wpse338050_replace_bar',9,3);
                  function wpse338050_replace_bar ($title,$raw_title,$context)
                  str_replace('


                  Beware I didn't test this. Some debugging may be necessary.






                  share|improve this answer















                  When WordPress inserts a post, it runs the title through a filter called sanitize_title to get the slug. By default there is a function called santize_title_with_dashes attached to this filter with priority 10. This function simply strips out the |. If it is surrounded by spaces those spaces will be converted to hyphens.



                  So your task is to run a filter on the same hook before (say, priority 9) the default one and replace the | with - before it gets stripped away. Like this:



                  add_filter('sanitize_title','wpse338050_replace_bar',9,3);
                  function wpse338050_replace_bar ($title,$raw_title,$context)
                  str_replace('


                  Beware I didn't test this. Some debugging may be necessary.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited 1 hour ago









                  Pat J

                  6,72812132




                  6,72812132










                  answered 5 hours ago









                  cjbjcjbj

                  11.3k103067




                  11.3k103067























                      0














                      If you put spaces in between the words and the separator | the permalink will automatically include dashes between the words. For instance try this as your post title:



                      house | something, bridge | somewhere


                      That results in the slug:



                      house-something-bridge-somewhere





                      share|improve this answer



























                        0














                        If you put spaces in between the words and the separator | the permalink will automatically include dashes between the words. For instance try this as your post title:



                        house | something, bridge | somewhere


                        That results in the slug:



                        house-something-bridge-somewhere





                        share|improve this answer

























                          0












                          0








                          0







                          If you put spaces in between the words and the separator | the permalink will automatically include dashes between the words. For instance try this as your post title:



                          house | something, bridge | somewhere


                          That results in the slug:



                          house-something-bridge-somewhere





                          share|improve this answer













                          If you put spaces in between the words and the separator | the permalink will automatically include dashes between the words. For instance try this as your post title:



                          house | something, bridge | somewhere


                          That results in the slug:



                          house-something-bridge-somewhere






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered 5 hours ago









                          MichelleMichelle

                          2,37631929




                          2,37631929




















                              Marg9 is a new contributor. Be nice, and check out our Code of Conduct.









                              draft saved

                              draft discarded


















                              Marg9 is a new contributor. Be nice, and check out our Code of Conduct.












                              Marg9 is a new contributor. Be nice, and check out our Code of Conduct.











                              Marg9 is a new contributor. Be nice, and check out our Code of Conduct.














                              Thanks for contributing an answer to WordPress Development Stack Exchange!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid


                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.

                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fwordpress.stackexchange.com%2fquestions%2f338050%2fdont-replace-with-empty-when-generating-slugs-from-title%23new-answer', 'question_page');

                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              Siegen Nawigatsjuun

                              Log på Navigationsmenu

                              Log på Navigationsmenu