Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
WPB Cup
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

Så här infogar du WordPress-sidans content till en annan page eller post

Vill du insert WordPress page content till en annan page eller post?

This allows you to create a piece of content once and then show it in multiple locations across your website. It can save you a ton of time and effort, especially when it comes to updating the content.

I den här artikeln kommer vi att visa dig hur du enkelt kan insert sidans content till en annan page eller post i WordPress, steg för steg.

How to insert WordPress page content into another page or post

Varför embedda page content till andra pages och posts i WordPress?

Att embedda page content till andra pages och posts i WordPress kan save you time.

Istället för att återskapa innehållet flera gånger kan du helt enkelt skapa sidan eller posten en gång och sedan embedda den på flera locations över hela din WordPress blogg. Detta är perfekt för gallerier, portföljer och andra websites där you ofta återanvänder samma content.

Det är också ett bra val om du vill visa samma reviews eller rekommendationer på din About page, WooCommerce produktsidor, homepage och andra locations.

Detta tillvägagångssätt gör det också lättare att updating your content. Istället för att editera flera pages kan du helt enkelt update ”källan”, och dessa ändringar kommer sedan att visas på hela din WordPress website.

Med det sagt, låt oss visa dig hur du inser page content till en annan page eller post i WordPress.

Lägga till WordPress Page Content i Pages och Posts

Det enklaste sättet att insert WordPress content i andra posts och pages är genom att använda Insert Pages. Detta plugin allow you att enkelt insert content med hjälp av ett block eller en shortcode.

Det första du behöver göra är att installera och aktivera pluginet. För mer detaljer, se vår Step-by-Step guide om hur du installerar ett WordPress plugin.

Efter aktivering öppnar du posten eller sidan där du vill embedda sidans content och klickar på ’+’ icon.

Click add block for page content

Du kan nu skriva in ”Insert Page”.

When the right block appears, click to add it to your website.

Select insert page block

Nästa steg är att välja den page som du vill embedda med hjälp av inställningarna i menyn till höger.

Under ”Infoga sida” kan du antingen enter sidans URL eller börja skriva dess titel, vilket öppnar en dropdown-meny. You can then choose the right page or post from the dropdown menu.

Adding page or post content to a WordPress page

Efter det kan du finjustera hur det inbäddade innehållet kommer att se ut i ”Settings” -sektionen.

I dropdown ’Display’ väljer du det content som du vill inkludera, till exempel postens titel, link, postens excerpt eller till och med hela sidans innehåll.

Select page or post display options

Du kan också lägga till custom CSS, välja att visa sidans content inline och till och med dölja pages för alla anonyma användare som inte har registrerat sig på din WordPress website.

När du är nöjd med hur innehållet ser ut, se till att klicka på knappen ”Update” eller ”Publicera” för att save your changes.

Nu, om du besöker ditt inlägg eller din page, kommer du att se sidans eller postens content embeddat i din WordPress website.

Embedded page content example

Använda shortcodes för att add to page content i WordPress

Om du inte vill använda blocket Insert Page kan du använda en shortcode istället.

Pluginet har shortcode-parametrar som låter dig customize det page content som du vill visa. Till exempel:

[insert page='page-slug|ID' display='title|link|content|all|custom-template.php']

Denna shortcode-metod kan vara snabbare om du vill add to samma content och styling till flera pages. Klistra bara in shortcoden var som helst på din site, så kommer WordPress att visa rätt content med rätt Styling.

I shortcoden ovan måste du ersätta 'page-slug|ID' med sidans eller postens slug eller postens ID.

För mer information, vänligen se vår guide om hur du hittar ID:n i WordPress.

Du måste också ändra'title|link|content|all|custom-template.php'till den typ av sidinnehåll du vill visa och den styling den ska ha.

Till exempel kommer shortcoden under att visa en page med ID:n ”128”. Den kommer också att visa sidans content:

[insert page='128' display='content']

För att placera shortcoden öppnar du bara ett post eller en page och klickar sedan på ”+” för att add a new block.

I popupen söker du efter ”Shortcode” och väljer sedan rätt block när det visas.

Add new shortcode block

Nu klistrar du bara in shortcoden i det nya blocket.

Se till att du klickar på knappen ”Update” eller ”Publicera” för att save your changes.

Enter page shortcode

När du har gjort det kan du besöka din WordPress website för att se den inbäddade sidan eller innehållet i posten live.

Så här infogar du WordPress Page Content i ditt WordPress Theme

Om du använder ett av de nyare temana för Full Site Editing kan du insert WordPress page content i valfri template eller template-del. Det här är ett enkelt sätt att visa samma content på flera pages. Du kan till exempel add to en customer review till all your blogg pages.

Det är också ett sätt att add to content till areas som du inte kan edit med WordPress standard content editor. Till exempel kan du insert page content i din 404 page template.

För att komma igång, heada över till Appearance ” Editor i WordPress dashpanelen.

Opening the WordPress full-site editor (FSE)

Som standard visar hela Site Editor ditt temas home page template, men du kan insert page content i vilket area som helst.

För att se alla tillgängliga alternativ, välj bara antingen ”Templates” eller ”Template Parts”.

Choosing a WordPress template or template part

Du kan nu clicka på den template eller template-del som du vill edit:a.

WordPress kommer nu att visa en preview av designen. För att gå vidare och insert page content, click på den lilla penna iconen.

Inserting page content into a WordPress theme

Du kan nu add to blocket Insert Page genom att följa samma process som beskrivs ovan.

Ett annat alternativ är att embedda sidans content med hjälp av Shortcode blocket. För att göra detta följer du bara instruktionerna ovan.

Inserting page content using the WordPress full-site editor

När du är nöjd med hur det inbäddade innehållet ser ut klickar du på knappen ”Save” för att aktivera det.

Lägga till custom post types till WordPress inlägg och pages

Om du använder custom post types för att organisera ditt content kan du också add to dessa till dina posts och pages.

Du kan till exempel skapa en custom post type för dina gallerier med images, videor, rekommendationer, portföljobjekt med mera.

För mer detaljer, vänligen se vår guide om hur du skapar custom post types i WordPress.

När du har addat en custom post type till WordPress, går du helt enkelt till den page eller det post där du vill embedda detta content. Du kan sedan infoga innehållet genom att följa samma process som beskrivs ovan.

Här är en page med content embed från flera posts som all har custom post typen ’Book’.

Custom post type books example

Använda Customize templates för att visa infogade pages

Som vi redan har sett har Insert Pages några inställningar som allow you att customize hur det infogade innehållet ser ut. Men om du vill ha full control över det inbäddade innehållet kan du skapa en custom page template.

Den här metoden kräver att du redigerar theme-filer och add to custom code, så den rekommenderas inte för Beginnare. Om du inte har editerat din websites code tidigare, vänligen se vår guide för nybörjare om hur du klistrar in snippets från webben till WordPress.

Vi rekommenderar också att du skapar en backup av WordPress så att du kan återställa din website om något går fel. För mer detaljer, se vår guide om hur du säkerhetskopierar din WordPress site.

När du har gjort det är du redo att skapa en custom page template.

Först öppnar du en plain text editor som Notepad och ger filen ett namn. Du kan använda vad du vill, men det är en bra idé att använda något beskrivande, som custom-page-template.php.

Klistra sedan in följande kod i den tomma filen:

<?php
/**
 * Template Name: Custom page template
 */
?>
 
<div id="your-wrapper-div">
  <?php while ( have_posts() ) : the_post(); ?>
    <div id="your-container-div-for-each-post">
      <?php the_content(); ?>
      <?php the_post_thumbnail(); ?>
    </div>
  <?php endwhile; ?>
</div>

Code snippet ovan är en mycket grundläggande mall, så du kanske vill customize den för att bättre passa dina feeds.

När du är nöjd med hur templaten ser ut är nästa steg att uppladare den till din WordPress theme folder.

Till att börja med måste du ansluta till din website via FTP eller filhanteraren på ditt webbhotell WordPress och sedan uploada filen till rätt folder.

För mer information, se vår guide om hur du använder FTP för att uppladare filer till WordPress.

Därefter öppnar du den page eller post där du vill använda den custom template. Öppna dropdown-menyn ”Display” i menyn till höger och välj ”Use a custom template”.

Du kan nu skriva ett snedstreck bakåt i fältet ”Custom Template Filename”, följt av namnet på templaten.

Select use custom template

När du är slutförd, se till att du klickar på ”Update” eller ”Publicera” för att göra dina ändringar live.

Bonus: Infoga annonser i innehållet på din page

Förutom att lägga till innehåll från en sida till en annan kan du också infoga annonser i innehållet på din page. Om du har en blogg i WordPress kan detta hjälpa dig att tjäna pengar online.

För att infoga annonser i sidans content måste du installera och aktivera pluginet WPCode eftersom det är ett bra verktyg för hantering av annonser.

Efter aktivering, besök sidan Code Snippets ” + Add Sn ippet och klicka på knappen ’Use Snippet’ under alternativet ’Add Your Custom Code (New Snippet)’.

Add a new custom code snippet in WPCode

Detta tar dig till sidan ”Create Custom Snippet” där du måste välja ”HTML Snippet” som kodtyp från dropdown-menyn.

Därefter klistrar du bara in din annonskod i boxen ”Code Preview”.

Copy and paste ad code into Code Preview box

När du har gjort detta rullar du ner till ”Location” section och selectar alternativet ”Insert After Paragraphh”.

Skriv sedan antalet stycken efter vilka annonsen ska infogas i innehållet på din page.

Select Auto-Insert Insert After Paragraph to insert ad within post content

Slutligen rullar du tillbaka högst upp och togglar omkopplaren ’Inaktiverad’ till ’Aktiv’. Klicka sedan på knappen ”Save Snippet” för att store dina settings.

Du har nu utan problem infogat en annons i innehållet på din page. För mer information kanske du gillar att se vår tutorial om hur du inser annonser i ditt page content i WordPress.

Vi hoppas att den här artikeln hjälpte dig att lära dig hur du infogar WordPress-sidans content i ett annat post eller page. Du kanske också vill se vår guide om hur man tjänar pengar på att blogga online med WordPress och våra expertval för de bästa tilläggen för landing pages.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Avslöjande: Vårt innehåll stöds av våra läsare. Det innebär att om du klickar på några av våra länkar, kan vi tjäna en provision. Se hur WPBeginner finansieras, varför det är viktigt, och hur du kan stödja oss. Här är vår editoriala process.

Avatar

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

Den ultimata WordPress-verktygslådan

Få GRATIS tillgång till vår verktygslåda - en samling WordPress-relaterade produkter och resurser som varje professionell användare bör ha!

Reader Interactions

27 kommentarerLämna ett svar

  1. Syed Balkhi says

    Hey WPBeginner readers,
    Did you know you can win exciting prizes by commenting on WPBeginner?
    Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
    You can get more details about the contest from here.
    Start sharing your thoughts below to stand a chance to win!

  2. Jiří Vaněk says

    I would like to ask, if I use this practice and have the same content inserted in multiple places, will it harm my SEO due to duplication? Is it necessary to somehow mark the content so that Google does not interpret it as duplication but rather as inserted content that is not necessarily duplicate?

    • WPBeginner Support says

      It heavily depends on the content, if it is a call to action then it wouldn’t be penalized but if it is the only content across multiple posts then it would be penalized.

      Administratör

      • Jiří Vaněk says

        I understand, I was actually referring to the text, not the call to action. So from your response, I gather that it’s not a good idea for me to have the same inserted text on multiple pages. Thank you for pointing that out. I’ll come up with a different approach to avoid duplication. Thanks for the advice, I probably would have harmed my website’s SEO without it.

        • WPBeginner Support says

          If it is a small excerpt it should be fine for your site but if it is the primary content then it would become a bad idea for your site.

  3. Philip L Franckel says

    I would like to use this to add contact info and a photo, like the author box, at the bottom of every page so I can update one page and automatically update all other pages. Will this plugin slow down my site?

  4. Bobby says

    Hi, I added the plugin & the code. It worked. but for example, when I have content in page2 and wanna copy the page1’s content in it, it doesn’t work.
    What should I do?

  5. Vico says

    I have a question:
    If I create a Page and display Post now I will have 2 identical contents: 1 for the page and the other in the post…Won´t that be duplicate content…?

  6. Jason says

    I am trying to use the insert page plugin but get two random issues.
    1. It doesn’t update the author. I created the post but switched it to someone else but when the plugin is enabled it continues to show me as the author and when I deactivate the plugin the author shows who I selected it to be.

    2. the plugin seems to disable the commenting system. When the plugin is enabled the comments do not show and when it is disabled they come back.

  7. Michael says

    Thanks for this great work.

    <Request: I use the default post type of WP to create my content, before I know about custom post type. Now, I would like to move Movie to the movie custom post section from the default, how can I do this or can I get a link to the tutorial you have that covers this.
    Hope to hear from you, thanks.

  8. Whit Wright says

    I have to add six separate posts to a collaborative WordPress.com blog for a school assignment. I already created the post in my own WordPress.com account, but I do not know how to transfer that post to the other blog. I tried a few options, but I am stuck. I Exported my post from my blog, but I do not see a way to Import it into the other blog. I also tried to install and use the ”Insert Pages: plugin, but, according to this post, I cannot use that plugin unless I transfer my site to WordPress.org. Does anyone have any suggestions?

    Thank you!

  9. Sam says

    Thanks for sharing this! I think this is just what I need to create author bios at the bottom of my posts without the security risks of adding new users.

  10. WPBeginner Staff says

    You can do this and if that serves the purpose. This method is more useful when you want to manage the contents of one page separately so that when you update that page the change appears on other posts/page where you have added it.

  11. mc says

    I’m not sure I understand why you couldn’t just copy and paste the text from one page into the new page.(and manually update any page links) … Would you use this if you wanted to keep the format/layout of the original page? Am I misunderstanding the question?

  12. Mo says

    Hi,

    Can you display a certain number of words rather then the full page and with a link to the full page?

    Thanks for sharing the infos on this plugin, can be very useful :)

    Mo

    • Jarkko Saltiola says

      Discussed plugin seems to be off from official repository but I found this plugin from Github github.com/uhm-coe/insert-pages. Just hit ”Clone or Download” and ”Download ZIP”, then upload the zip file and install.

  13. Don Avant says

    Or I could just open both pages/posts and copy and paste…Simpler, I don’t to download and install a plugin and I already know how to do this…

    • Chrymo says

      In some cases, when you create a custom page template just for one particular page but only allow a simpler page for edits of the content area.

      I.e. target page has all the bells and whistles you dont want to frequently edit. But a part of that page you want to have someone edit for you. You use the trick above so others can edit that content but not your layout for one particular page.

Lämna ett svar

Tack för att du väljer att lämna en kommentar. Tänk på att alla kommentarer modereras enligt våra policy för kommentarer, och din e-postadress kommer INTE att publiceras. Vänligen använd INTE nyckelord i namnfältet. Låt oss ha en personlig och meningsfull konversation.