Comment Function

the function you posted is limited to 5 comments which means it should work, but anyway there is no need for a custom SQL query when you can use the native get_comments function function showLatestComments() { $comments = get_comments(array( ‘status’ => ‘approve’, ‘number’ => ‘5’ ) ); $output .= ‘<h2>Latest student perspectives <img src=”https://wordpress.stackexchange.com/wp-content/themes/blue-and-grey/images/hmepage-tri.png” class=”class3″ … Read more

Modifying Page-Links format

One easy way to do this is to alter the global variables related to paging after calling the_post() in your loop. global $post, $pages, $numpages, $multipage; while( have_posts() ) { the_post(); if( is_mobile() ) { $pages = array( $post->post_content ); $page = $numpages = 1; $multipage = false; } // … template the_content(); } Basically … Read more

Syntax for a function in order to get post’s title in JSON encoded response [closed]

You want to add the title to the response, not replace the response with the title. Like this: <?php function get_all_images($post_id=0, $size=”bigger”, $attributes=””) { $post_id = $_POST[‘post_id’]; if ($post_id<1) $postid = get_the_ID(); if ($images = get_children(array( ‘post_parent’ => $post_id, ‘post_type’ => ‘attachment’, ‘numberposts’ => -1, ‘orderby’ => ‘menu_order’, ‘post_mime_type’ => ‘image’,))) $title = get_the_title($post_id); $response=”<h2 … Read more

Ajax call does not work for this custom code

Instead of doing: data: {action: ‘performers’, catname: catname} Try: data: ‘action=performers&catname=”+catname; You may also want to define “catname” globally, i am not sure if scope is an issue with your ajax handler but this could be why it is not being set. As an example try to alert catname within the ajax handler above cache=false; … Read more

Echo a div to header.php from functions.php

The wp_head() template tag is intended to fire in the HTML document head, rather than the page header, and is used to output script and stylesheet links and tags, and other similar things in the HTML document head. It should appear immediately before the closing HTML </head> tag, like so: <?php wp_head(); ?> </head> If … Read more

How to shorten code with function?

You can make your own function to minimize the characters typed for each time you want to repeat the call to get_posts: in functions.php (perhaps): function print_piwa($postcount=2, $cat_id=81) { ?> <div class=”wiadPodtyt”> <ul> <?php $piwa = get_posts(array( ‘posts_per_page’ => $postcount, ‘cat’ => $cat_id, ‘post__not_in’ => $news_ids, ‘offset’ => 1 )); foreach ($piwa as $post) { … Read more