0

I want to create dynamic content that is taken from a specific paragraph from one page and writes to a paragraph on multiple pages that feature that same content. I am new to PHP and not sure how to make this happen in WordPress.

I have an existing WordPress webpage, let's call it the Plan, with paragraphs on it. The content of these paragraphs changes from time to time. The content in the Plan paragraphs is also on other existing WordPress pages, call these other pages Profile pages. I am trying to be more efficient by only writing the content once on my website and feature that content on other webpages with some script. I can give the paragraphs on the Plan page IDs.

On the Profile pages, how do I call specific paragraph IDs from the Plan page to write the paragraph content?

1
  • 2
    Could you provide more extensive example maybe? Do you mean existing WordPress page pages, or URLs, or what?
    – Rarst
    Commented May 8, 2015 at 21:32

3 Answers 3

1

In addition to what has been mentioned above, I see another alternative: WP options. You could:

  1. Create a page in the admin panel that will have a bunch of <textarea> elements, each <textarea> containing a paragraph
  2. Save the values of these <textarea>s to wp_options table of your DB;
  3. Register a shortcode to display the values of these options (e.g. here’s a plugin for this; I haven’t tested it);
  4. Include the shortcode with an attribute specifying the particular option (paragraph of the plan) every time you want a Plan paragraph to be included in a post or page.
0

The WordPress doesn't operate with concept of partial content. The content of the post is seen as single block of text/markup, possibly with embedded external elements. Even in latter case that is considered one way flow — content output will process embeds, but embeds aren't meant to be extracted from content.

In your case I would guess the data architecture would depends on how standalone "paragraphs" really are.

I see roughly two cases:

  1. Paragraph is a Custom Post Type (each of them, or post per collection of paragraphs), which are created/managed independently and which pages & profiles embed in some form.

  2. Paragraphs are a Custom Field of page (part of its meta data) and managed together with it, which profiles access through the page's ID.

1
  • Thank you I will research Custom Post Types and Custom Fields for WordPress and see if these are solutions and will post my findings. Commented May 11, 2015 at 14:17
0

Another workaround that you could do is creating a widget of this paragraph.

You will need to install a plugin as described in: How to Add WordPress Widgets in Post and Page Content

You can now make a text widget of this paragraph and just add [do_widget paragraph] on all your pages where you want to show the paragraph. (the word paragraph in this example is variable to the name that you are giving the widget).

Changing the widget text will now change the text on all pages in one save

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.