Need to insert code in the correct place

Posted in: ionMag
Post count: 9

Hello,

I have almost everything working except one thing.

I want to use the REST API to call an article from my other WordPress site and display it on the site using the WPIon template.

The code works and was tested using the vanilla site, but now that the template is installed, I am a bit lost.

I have created a static homepage. Using the TAGDIV editor, I created the most basic page with one element (a full width image/link). What I need to do is use the following code:

<?php
$newsletter_posts = get_newsletter_posts();

if ( $posts ) {

foreach ( $newsletter_posts as $news_post ) { ?>

link ); ?>” title=”<?php echo esc_attr( $news_post->title->rendered ); ?>”><?php echo esc_html( $news_post->title->rendered ); ?>

<?php }

}
?>

To call the article and display it in this area as a full width header image/link. As you can see, the code currently creates a static link, but it needs to appear exactly like it does on the other site. The problem is I can’t figure out all these pages to determine where to put this code, and which HTML to use instead of the <a/a> tag.

I could edit the page.php file, but I don’t want this to show up on every other page, just the static home page (currently named “Home”)

If anyone can help me figure out which template files I need to alter to get this working, I would appreciate it very much.

Thanks!

  • This topic was modified 1 week by  RCMSAR.
  • This topic was modified 1 week by  RCMSAR.
Post count: 9

Here is the link.

https://sarpublic.mywhc.ca

Simion C.
Post count: 218

Hi,

The theme Grids and blocks will display posts actually created and published. That is how the filtering and sorting is based on as well, to pick posts. The theme does not have any options to pull and display posts from other websites in the grids and blocks. Also the thumbnail has to be created from the featured image manually set for each post.
Maybe you can create the post normally, then there will be no problem placing it in that grid.

Thanks

Post count: 9

Correct. I am using WordPresses’ built in REST API to pull the information from the other WP site and display in the other site. I have successfully connected to, and pulled the information.

The thumbnail is created on the other site, and is part of the data I am pulling using the REST API.

What I need help doing is integrating the code into the theme. So for example, when using the TAGDIV editor, instead of putting a block in there, I would leave that area blank. That is where I would integrate the REST API code.

What I need help doing is finding the correct file(s), and the correct spots in the code. I don’t know this theme all that well, so I am having trouble finding the correct files and place to do it. I also need to figure out the CSS used in the theme so I can make it look correct.

Creating the post normally is not an option. The client requires the news article to be posted by the author on the newsletter site, and the public site is referencing these articles. They don’t want to give the author access, nor do they want to create multiple instances of the same article on different sites.

Post count: 78

Another option is to use something like FeedWordPress to pull in the content from the other site via RSS2. We do this with our main news portal, and then pull in localized content to the child sites. Might not be what you’re looking for, but we use it every day across 12 sites flawlessly. This way content is pulled in to the theme as default post content not a bunch of custom hooks; but FWP supports taking custom fields included in the original source and integrating into the new site fields.

Food for thought anyway. 🙂

Sometimes simpler to make a custom feed from ‘site a’ to pull in content to ‘site b’ than hack the crap out of site b to get it to work with site a.

Post count: 9

Thanks for the advice. It is a little clunky but so far it seems to be doing the trick. The problem is that I can’t seem to get it to pull the “Featured Image” from the other site.

I installed the extra FWP+: SIC ‘Em plugin from the same developer, and it will pull an image from the original article, but not the featured image. I am hoping this is solvable.

Post count: 78

I use the ‘auto post thumbnail pro’ plugin to grab first external image from our ‘site a’ in the post and make into the featured image for the clones on ‘site b,c,d,e’. Best $10 I ever spent.

Post count: 9

The plugin you’ve suggested appears to be a manual process. What I mean is, it only seems to generate thumbnails for posts that have already been added. So unless I am mistaken, someone would have to login and manually press this button after publishing an article on the other site?

Post count: 9

I used a plugin to achieve a similar thing in my blog with Ionmag theme, it’s called FeedWordpress, maybe you could use it for your blog RCMSAR.

Link: https://es.wordpress.org/plugins/feedwordpress/

Edited: Sorry I see that SimChris already had recommended that plugin.

  • This reply was modified 2 days by  nakoruru666.
  • This reply was modified 2 days by  nakoruru666. Reason: I've readed all post XD
Viewing 9 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic.