最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

plugins - How to prevent redoing get_posts queries and make results available to other scripts?

programmeradmin0浏览0评论

I am modifying a wordpress site that is for online lessons.

I am modifying the lesson template which originally had one navigation sidebar for a lesson.

I have added a vertical tab switcher so that I can display other things related to lessons (so I will have dynamic vertical tabs where user can choose syllabus, tasks, discussions in navigation bar) and in stepping through the code in PHPStorm with xdebug I noticed that there are a lot of calls to get_posts() made in various template part builders.

So you have this sort of structure:

Load lessons navigation menu
    Display basic lesson info
    Call a function to get topics and display topics
        Call another function to get topic quizzes
...

Now display main content

The thing is, a lot of the info I want to display in other navigation tabs (, say tasks, discussions) is info already extracted in previous function calls for building the syllabus navigation tree but which are not available to me after the function's return back to the main template.

Now, I can redo various function calls, but seems like such a waste.

How does one typically pass post data among the various scripts that are used to render a page so that you don't have to redo queries?

Above said, would something like angularjs be a better approach to dealing with post data and having it available to all the HTML elements that I deem necessary?

Just trying to figure out how you typically address this sort of data sharing across scripts without just declaring a bunch of globals (or is that valid way?)

thanks,

Brian

发布评论

评论列表(0)

  1. 暂无评论