1

is there a way to load a page content ( or an element ) from a page into another one on a same Wordpress website? For example, if I had a page with some links would it be possible to make a specific element ( such as a div ), that comes from an another page, appear in a specific part of the page? If it was possible, can anyone help me reaching out the best way to do it ( which language use and in which way use it ) ? I hope someone could help me, thanks.

1 Answer 1

0

If you wanna call content of one page to another page then for that you need to make custom template.

For example if you have 2 pages (page a and page b) then make template for page a. And now you want to add content of page b into page a, this can be done with following code

$include = get_pages('include=10'); //Assigning ID of page
$content = apply_filters('the_content',$include[0]->post_content);
echo $content;

In the above code code I have assign ID 10 to get_pages() function, just for demo purpose. Replace 10 with your actual page ID whose content you want to show in page a.

Just Paste the above code in custom template (made for page a) on location of your choice and page b content will get appear on that location.

2
  • Useful reply, but I wanted to make a page where the user could choose a specific div of another page dynamically through a list of some links...so each link would generate a dynamic content without page refresh. Practically, this problem could be solved with AJAX and Javascript, but I could not do it with Wordpress.
    – Michele
    Commented Nov 21, 2016 at 9:15
  • @Michele You haven't mentioned this in your question earlier, that's why I came up with this solution. If you want to do it without page load then sorry to say but I can't help you in that because I don't have knowledge of AJAX.
    – Rishabh
    Commented Nov 21, 2016 at 9:31

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.