• 0

PageLines Framework and get_template_part() to get post loop only


Question

Posted · Report post

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

10 answers to this question

  • 0

Posted · Report post



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
  • 0

Posted · Report post

Hi,

 

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

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

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
  • 0

Posted · Report post

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?

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

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
  • 0

Posted · Report post

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
  • 0

Posted · Report post

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
  • 0

Posted · Report post

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/

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now