kapiljainin
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: query_posts: combine category__in with tag__inHi,
Here is the code for displaying related posts based on the current post categories and tags:
<?php
//for use in the loop, list 5 post titles related to tags and categories on current post//Getting categories of the current posts
$post_categories = get_the_category($post->ID);
if ($post_categories) {
for($i = 0; $i < count($post_categories); $i++){
$my_categories .= $post_categories[$i]->term_id . ‘,’;
}
}//Getting tags of the current posts
$post_tags = wp_get_post_tags($post->ID);
if ($post_tags) {
foreach($post_tags as $tag) $my_tags[] = $tag->term_id;
}echo ‘Related Posts’;
$args=array(
‘tag__in’ => $my_tags,
‘cat’ => $my_categories,
‘post__not_in’ => array($post->ID),
‘showposts’=>5,
‘caller_get_posts’=>1
);
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
while ($my_query->have_posts()) : $my_query->the_post();
//Add code for display posts
endwhile;
}
?>Forum: Fixing WordPress
In reply to: Dynamic list of links to posts of a given category on a pageAnother error in your code is that you missed out the reset the query.
To reset query use
<?php wp_reset_query();?>
just after endwhile loop.<?php endwhile; ?> <br /><br />
will be changed to<?php endwhile; ?> <?php wp_reset_query();?> <br /><br />
Forum: Fixing WordPress
In reply to: Removing Privacy Page From Top MenuHi,
You have to exclude privacy page from navigation list.
wp_list_pages('exclude=32') // 32 is privacy page id in https://getloadsmorecustomers.co.uk/ and 67 in https://stopthatbreakup.com/
Mostly this function is called in header.php file of your theme.
To learn more about wp_list_pages() function https://codex.www.ads-software.com/Template_Tags/wp_list_pages
Forum: Themes and Templates
In reply to: Crappy tag cloud spacingYou are using widget to display tags (GLITTER) in your site.
Use the following in style.css of the theme
li#tag_cloud a {
line-height: 1.0;
}Play with line-height til you find the setting you like – .9, .8, 1.1 etc.
By default smallest font size of a Tag is 8pt and largest is 22pt, to change it you have to add tag cloud manually in sidebar.php
For more details https://codex.www.ads-software.com/Template_Tags/wp_tag_cloud
Thanks
Forum: Themes and Templates
In reply to: wp_list_pages sub sub-pagesThis link might help you.
https://kapiljain.in/blog/how-to-get-page-root-parent-in-wordpress/
Forum: Fixing WordPress
In reply to: Searchbar style problem?Add in #searchbox .textfield css
border: 1px solid #000000;
You can change border size, style, color as per your requirement, by default border of text field is 1px solid.
Thanks
Forum: Themes and Templates
In reply to: help with the categories orderIts works fine for me.
Sent updated pages via email.
Forum: Themes and Templates
In reply to: help with the categories orderHi,
Theme developer use get_categories() function of wordpress for list categories in this theme.
By default this function display list of categories order by name. You can change it by adding a parameter get_categories() function as get_categories(‘orderby=ID’).
For more details of this function go to https://codex.www.ads-software.com/Function_Reference/get_categories
I found get_categories() function following pages:
1. header.php
2. sidebar.php
3. functions.php
4. index.phpReplace get_categories(‘hide_empty=0’) with get_categories(‘hide_empty=0&orderby=ID’) in above mentioned pages where you want to change order of categories.
Hope now it works fine for you.
Note: please take a backup before making any changes.
Also replied over mail.
Thanks
Kapil JainForum: Themes and Templates
In reply to: help with the categories orderHi amitrozen,
This is a premium theme and I don’t have access to the theme pages.
If your share the theme with me I will try to resolve this issue.
You may send it at [email protected] or [email protected]
Thanks
Kapil JainForum: Themes and Templates
In reply to: Help limiting number of post…Hi,
Use the following code, hope works for you.
<?php $i = 0; ?> <?php if (have_posts()) : while (have_posts()) : the_post(); if( $post->ID == $do_not_duplicate ) continue; update_post_caches($posts); $i++; if ($i<=3) {?> <div class="span-8 post-<?php the_ID(); ?> <?php if ($i == 3) { ?> last<?php } ?>"> <h6 class="archive-header"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title() ?></a></h6> <?php echo get_the_image_link(array('thumbnail','thumbnail-news'),'thumbnail'); ?> <?php the_excerpt(); ?> <p class="postmetadata"><?php the_time('M d, Y') ?> | <?php comments_popup_link('Have your say ?', '1 Comment ?', '% Comments ?'); ?></p> </div> <?php } ?> <?php endwhile; endif; ?> <div class="archive-stack clear"></div>
Thanks
KapilForum: Themes and Templates
In reply to: Help limiting number of post…You can set number of post in a page from wordpress admin.
Go to wp-admin > Settings > Reading and change the value of Blog pages show at most textbox to 3.
Forum: Themes and Templates
In reply to: help with the categories orderI think this is a typo mistake.
Replace <?php echo $result->id; ?> with <?php echo $result->term_id; ?> in line # 9
Hope it works for you.
Thanks
Forum: Themes and Templates
In reply to: help with the categories orderHi,
Use the following code to display categories order by ID
<div id="middle" class="clearfloat"> <?php global $wpdb; $query = "select t.term_id, t.name, t.slug, tx.description as catDes from $wpdb->terms t, $wpdb->term_taxonomy tx where t.term_id = tx.term_id and tx.taxonomy = 'category' order by t.term_id"; $results = $wpdb->get_results($query); foreach ($results as $result) { $catPermalink = get_bloginfo('url') . "/category/" . $result->slug . "/"; ?> <div id="cat-<?php echo $result->id; ?>" class="category" onclick="window.location.href='<?php echo $catPermalink;?>';"> <span class="cat_title"><?php echo $result->name ?></span> <p><?php echo $result->catDes;?></p> </div> <?php } ?> </div>
Forum: Themes and Templates
In reply to: restrict the number of posts on front pageHi Michael,
Thanks for quick reply.
I have already try this, but not worked.
The reason of the Error is, if the number of pages according to the wordpress blog setting (from reading section of wp-admin) is less than the current page (using query_posts function) is shows 404 error message.
For example,
if I have 7 posts in my blog and set Blog pages show at most to 5. It means my blog have 2 pages.
and if I display 2 post in my home page using query_posts function, my home page shows 4 pages.
It works fine for first 2 pages but shows 404 error in 3rd and 4th page.
Any idea how to resolve this issue.
Thanks
Kapil JainForum: Themes and Templates
In reply to: Unable to change image class using Thumbnails for ExcerptsHi,
Try by changing .imgtfe to .imgtfe, .entry .imgtfe in above mentioned css class name.
Thanks
Kapil Jain