AJAX in wordpress theme loop
You need to set user logged in condition on button/ link which triggers ajax request, eg, if user is not logged in open login modal else your function.
You need to set user logged in condition on button/ link which triggers ajax request, eg, if user is not logged in open login modal else your function.
I use wp_trim_words to create multiple excerpts. I always abuse it when I need more than one excerpt length. Here is how function wpse_custom_excerpts($limit) { return wp_trim_words(get_the_excerpt(), $limit, ‘<a href=”‘. esc_url( get_permalink() ) . ‘”>’ . ‘ …’ . __( ‘Read more »’, ‘wpse’ ) . ‘</a>’); } What this function do is taking get_the_excerpt trimming … Read more
I don’t believe the code worked what you have posted. If you simply copied and pasted it from your template, it would never have worked. There are a couple of syntax errors/bugs in your code <?php if((have_posts)): ?> should be <?php if(have_posts()): ?>. <?php $count ?> What does this mean. This is suppose to update … Read more
Just before the while loop starts, have a counter variable like $counter = 0; Just before the endwhile, add the following check with counter. if ( ++$counter == 10 ) { $dee_output .= ‘</div><div class=”second-half”>’; } Note: I don’t see correct number of opening and closing div tags, so please check your code.
Like @jdm2112, I’m not a Gensis user, but here is an alternative method to retrieving the featured image. I use this method because it offers more functionality to altering the featured image (ie: thumbnail size). You can add these functions to your functions.php file. public function get_featured_image_id() { return (int) $this->get_meta( ‘_thumbnail_id’ ); } /** … Read more
I suspect that your issue is occuring because the category term events does not yet exist. If the function get_cat_ID() fails it returns 0, and in turn the wp_get_recent_posts() function uses 0 as the default for the category parameter, meaning that the parameter is ignored by the function. To avoid this behaviour I suggest you … Read more
For the example you posted, the article is styled according to the css rule(s) for category-selling-and-advertising which is defined last (among the category-* classes) in the article’s class attribute. You need to intercept the functionality of post_class() to change the order these classes appear. The post_class filter will do the job for you: add_filter( ‘post_class’, … Read more
This is the source of all your problems: <?php if(is_home() && !is_paged()) { ?> <?php query_posts(array(‘post__in’=>get_option(‘sticky_posts’))); ?> This takes the current query, and puts it to one side, and places a new query in its place. Here you’re saying that you want to show the first page of sticky posts. You said nothing about tags … Read more
This is strange and should not happen by default. get_posts uses WP_Query. If you look at the source code of get_posts, all the parameters passed to get_posts is passed unchanged to WP_Query except parameters like category which is changed to cat, the include and exclude parameters to include or exclude certain posts which is changed … Read more
I think you are doing this right… but in the wrong direction. What if you separate your default structure like: content-header.php <?php get_header(); get_sidebar(); ?> <div id=”content”> content-footer.php </div> <?php get_footer(); ?> And then you can use get_template_part to put all together: index.php <?php get_template_part( ‘content’, ‘header’ ); ?> <?php while ( have_posts() ) { … Read more