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

Error when running ((x++)) as root

Real-life exceptions to PEMDAS?

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

Largest memory peripheral for Sinclair ZX81?

Pedaling at different gear ratios on flat terrain: what's the point?

I recently started my machine learning PhD and I have absolutely no idea what I'm doing

Can more than one instance of Bend Luck be applied to the same roll?

Why use a retrograde orbit?

Why does the U.S military use mercenaries?

Who is frowning in the sentence "Daisy looked at Tom frowning"?

Are spiritual pleasures > carnal pleasures, according to Catholicism?

Cryptic crossword (printer's devilry edition)

Have the writers and actors of GOT responded to its poor reception?

Gambler's Fallacy Dice

Will this series of events work to drown a tarrasque?

Can ThermodynamicData be used with NSolve?

Have GoT's showrunners reacted to the poor reception of the final season?

Driving a school bus in the USA

Told to apply for UK visa before other visas

How would fantasy dwarves exist, realistically?

Hotel booking: Why is Agoda much cheaper than booking.com?

Appropriate liquid/solvent for life in my underground environment on Venus

What color to choose as "danger" if the main color of my app is red

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



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 4 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) ','-',$title);
          return $title;



          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) ','-',$title);
              return $title;



              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) ','-',$title);
                return $title;



                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) ','-',$title);
                  return $title;



                  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) ','-',$title);
                  return $title;



                  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 4 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 4 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

                              Canceling a color specificationRandomly assigning color to Graphics3D objects?Default color for Filling in Mathematica 9Coloring specific elements of sets with a prime modified order in an array plotHow to pick a color differing significantly from the colors already in a given color list?Detection of the text colorColor numbers based on their valueCan color schemes for use with ColorData include opacity specification?My dynamic color schemes

                              Invision Community Contents History See also References External links Navigation menuProprietaryinvisioncommunity.comIPS Community ForumsIPS Community Forumsthis blog entry"License Changes, IP.Board 3.4, and the Future""Interview -- Matt Mecham of Ibforums""CEO Invision Power Board, Matt Mecham Is a Liar, Thief!"IPB License Explanation 1.3, 1.3.1, 2.0, and 2.1ArchivedSecurity Fixes, Updates And Enhancements For IPB 1.3.1Archived"New Demo Accounts - Invision Power Services"the original"New Default Skin"the original"Invision Power Board 3.0.0 and Applications Released"the original"Archived copy"the original"Perpetual licenses being done away with""Release Notes - Invision Power Services""Introducing: IPS Community Suite 4!"Invision Community Release Notes

                              François Viète Contents Biography Work and thought Bibliography See also Notes Further reading External links Navigation menup. 21Google Bookspp. 75–77Google BooksDe thou (from University of Saint Andrews)ArchivedGoogle BooksGoogle BooksGoogle BooksGoogle booksGoogle Bookscc-parthenay.frL'histoire universelle (fr)Universal History (en)ArchivedAdsabs.harvard.eduPagesperso-orange.frArchive.orgChikara Sasaki. Descartes' mathematical thought p.259Google BooksGoogle BooksGoogle Bookspp. 152 and onwardGoogle BooksGoogle BooksScribd.comGoogle Books1257-7979Google BooksGoogle BooksGoogle BooksGoogle BooksGoogle BooksGoogle BooksGallica.bnf.frGoogle BooksGoogle Books"François Viète"Francois Viète: Father of Modern Algebraic NotationThe Lawyer and the GamblerAbout TarporleySite de Jean-Paul GuichardL'algèbre nouvelle"About the Harmonicon"cb120511976(data)1188044800000 0001 0913 5903n82164680ola2013766880073431702w6vt1sb70287374827140948071409480