Editing Existing WordPress Loop

Posted in: Newsmag
Post count: 19

What I’m trying to do is alter the loop across my site so it will check the site URL so it will know which content to display based on tag.

For example, if I give some posts the tag “golfclubs”, I want it to work something like this:


if ($_SERVER['HTTP_HOST']=="www.golfclubreviewdomain.com"){
        // code here to display only the "golfclubs" tagged posts within the loop
}

And my final question, what change do I make to display more than 1 type of tagged post? maybe something like “golfclubs” and “general”?

Where would I place this code to make the changes to every loop across my site?

  • This topic was modified 10 years by jaysmg.
Post count: 9544

I think you’d have to edit each loop in each templtate file you’re actually using — so if you’re using post template 4, you’d likely edit the somewhat obviously named theme file: loop-single-4.php

Post count: 6535

Hi

For posts displayed in blocks you have to edit the td_data_source.php file http://screencast.com/t/wjLPyZxqrI If you want to alter the category page for example or any other page which use the loop.php file, you need to add your customizations in functions.php file. Fore more details about the posts query check this link: https://codex.wordpress.org/Function_Reference/query_posts
Please consider that this is a complex task which require good coding skills and if you’re not aware of the steps you need to take in this regard please consider hiring a developer or a freelancer to do this for you as we can’t offer any type of custom work at the moment.

Thanks!

Viewing 3 posts - 1 through 3 (of 3 total)
The forum ‘Newsmag’ is closed to new topics and replies.