Jump to content

Archived

This topic is now archived and is closed to further replies.

zouleo

PageLines Framework and get_template_part() to get post loop only

Recommended Posts

zouleo    1
zouleo

How can I use get_template_part() function to return the postloop template? I'm using the following code, and it's not working.

add_action('wp_ajax_nopriv_update_search', 'ajax_update_search'); // for not logged in users
add_action('wp_ajax_update_search', 'ajax_update_search');
function ajax_update_search() {
	$args = array(
		....
		'posts_per_page' => 10
	);
	$wp_query = new WP_Query( $args );
	get_template_part( 'sections/postloop', 'section');
	exit;
}

Share this post


Link to post
Share on other sites
zouleo    1
zouleo


add_action('wp_ajax_nopriv_update_search', 'ajax_update_search'); // for not logged in users
add_action('wp_ajax_update_search', 'ajax_update_search');
function ajax_update_search() {
	$args = array(
		....
		'posts_per_page' => 10
	);
	$wp_query = new WP_Query( $args );

	$theposts = new PageLinesPosts();
	$theposts->load_loop();

	exit;
}
I almost got it working now using load_loop(). But the strange thing is that I get the output from the starndard loop, not my PageLines designed loop.
 
What could be wrong?

Share this post


Link to post
Share on other sites
Danny    1,327
Danny

Hi,

 

I am not quite sure what is it you're trying to achieve, can you provide more information please.


Please search our forums, before posting!

Share this post


Link to post
Share on other sites
zouleo    1
zouleo

My problem is that load_loop() doesn't return the loop according to my PageLines settings. For example: I have set "Allow Tags in Excerpt" to be "<p><div><span><img><i><a>". But when using load_loop() the excerpt contains <strong>

 

Do you know what could be causing this?

Share this post


Link to post
Share on other sites
James B    436
James B

Is the strong tag inside one of the <div> or other tags anywhere in the excerpt? By the default wp strips out all of the tags other than the ones you set, if you remove the filter does the strong tag still appear in the excerpt?


Kindly search the forum and read the documentation before posting. It will help you resolve many issues.

For CSS help be sure to check out W3Schools first and be sure to download FireBug for FireFox for troubleshooting.

James B

Share this post


Link to post
Share on other sites
zouleo    1
zouleo

It's working on my front page, search result, archive pages etc. But when using load_loop() it's not. What could be the problem?

James B: I'm not sure what filter you are referring to. I'm not using any filter. I'm just using the PageLines settings.

Share this post


Link to post
Share on other sites
zouleo    1
zouleo

I'm probably doing it the wrong way. According to the Wordpress documentation it should be possible to use get_template_part() to get a part of the template. I've tried get_template_part( 'sections/postloop', 'section') but that doesn't work.

 

http://codex.wordpress.org/Function_Reference/get_template_part

Does anyone know how I can get the post loop section only?

Share this post


Link to post
Share on other sites
zouleo    1
zouleo

I read in a old topic from 2010 that at that time there was one file that controlled the loop and one file that controlled layout.

http://forum.pagelines.com/topic/2813-custom-post-templates/?p=33174

I am able to get the post loop using load_loop(), but layout is missing. Obviously the theme has changed a bit since 2010, but maby I still need to do something extra to get they layout in the loop?

Share this post


Link to post
Share on other sites
Rob    547
Rob

Hi Zouleo,

First, I think part of the problem is that the WP information you're referring to is referring to themes with standard templates.  Ours are dynamic in Framework, so likely that code won't apply.

 

If you're trying to "return the result of a query in html", it's probably best to use a plugin for it.  I don't know how we could support this, since none of the moderators are coders.  Our developers would likely recommend you engage a professional developer for this goal.  But I still believe you'll likely find a plugin to help.

 

Almost anything will return in HTML, essentially, since Framework is built on HTML5.  There are many query plugins, and many using Ajax.  This is just an example of one such plugin: http://wordpress.org/plugins/ajax-wp-query-search-filter/


Former PageLines Moderator, Food Expert and Raconteur

Share this post


Link to post
Share on other sites
zouleo    1
zouleo

Maby a developer could have a look at my question? My guess is that the answer is very simple, if you just know how to do it. In normal themes it is only one line of code:

get_template_part( 'sections/postloop', 'section');

 

Thank you

Share this post


Link to post
Share on other sites

×