Subrata Sarkar
Forum Replies Created
-
Forum: Plugins
In reply to: [Breadcrumb NavXT] Same Breadcrumb is displayed on different pagesI am new to WP. Would you mind explaining what exactly I need to do to make the breadcrumb working correctly?
Thank you for your help!
Forum: Themes and Templates
In reply to: [evolve] category posts – show in fullI do’t know much about the template you are using. But what you are saying is basically you want to show full posts in category page rather than having teasers.
If I understand correctly you have to create a php file named
categopry.php
in your theme’s root directory. In this page retrieve all posts under selected category and loop through them to display information the way you want.In
category.php
:$cat_name = single_cat_title('', false); //gets you current term name $this_cat = get_category_object($cat_name); // see below for f(n) body $cat_id = $this_cat->term_id; $posts = get_posts_by_category_id($cat_id, 'trips', 24); // see below for f(n) body <?php foreach($posts as $post) : setup_postdata($post); ?> <!-- Extract your data for each post --> <div> <p><?php echo the_title(); ?> </p> <p><?php echo the_content(); ?> </p> <p><?php echo get_the_post_thumbnail(); ?> </p> </div> <?php endforeach ?>
In your
functions.php
write the following functions:function get_category_object($cat_name){ $term = get_term_by('name', $cat_name, 'category'); return $term; }
and
function get_posts_by_category_id($cat_id, $post_type, $records_per_page){ $currentPage = get_query_var('paged'); $args = array( 'category' => $cat_id, 'post_type' => $post_type, 'paged' => $currentPage, 'posts_per_page' => $records_per_page ); $posts = get_posts($args); return $posts; }
Let me know if this helps.
- This reply was modified 7 years, 9 months ago by Subrata Sarkar.
Forum: Themes and Templates
In reply to: [evolve] category posts – show in fullsorry, your question is not very clear.
Do you mean you are not able to see the post content in full in post page? Rather you are only seeing excerpt and a Read More button?
Can you explain your requirement in detail?
Forum: Themes and Templates
In reply to: [Pinnacle] Limit excerpt and remove read moreIf length worked right then the other one should also work. There is no reason for this to not work. I hope you added
add_filter('excerpt_more', 'custom_excerpt_more_link');
in yourfunctions.php
along with the function body.Forum: Themes and Templates
In reply to: [Pinnacle] Limit excerpt and remove read moreBut the length did?
Forum: Themes and Templates
In reply to: [Pinnacle] Limit excerpt and remove read moreYou can customise how excerpt would display by adding a function and by adding a filter in your theme’s
functions.php
file.Try this:
function custom_excerpt_more_link($more){ return '<a href="' . get_the_permalink() . '" rel="nofollow"> [more]</a>'; } add_filter('excerpt_more', 'custom_excerpt_more_link');
The above function will remove default
Read More
link and display[more]
instead.To control length of your
excerpt
you need to write another function and add filter for the same:function set_custom_excerpt_length(){ return 40; } add_filter('excerpt_length', 'set_custom_excerpt_length', 10);
excerpt_more
andexcerpt_length
are the filters you have to pick up outputs from your above custom functions.Now you can use <?php the_excerpt(); ?> in your page to see them in action.
Hope this will help!
- This reply was modified 7 years, 9 months ago by Subrata Sarkar.
Forum: Themes and Templates
In reply to: [MesoColumn] Different colour schemeIdeally you should write your own CSS rules ina separate file to override default theme CSS rules and enqueue it through your theme’s
functions.php
file.For example you create your own CSS rules in a file called ‘my-custom.css’. Then you need to put it like this in
functions.php
:function add_custom_resources(){ wp_enqueue_style('my-custom', get_stylesheet_uri(), array(), mt_rand(), 'all'); } add_action('wp_enqueue_scripts', 'add_custom_resources');
This will ensure that even you update the theme your overridden rules will not get affected still remain in your custom style sheet.
Hope this helps.
Forum: Themes and Templates
In reply to: [MyKnowledgeBase] Alphabetical ArchivesYou are welcome. Glad that helped you!
Forum: Themes and Templates
In reply to: [MyKnowledgeBase] Alphabetical ArchivesHi,
You can try this in your theme’sfunctions.php
file:function order_category_archives_by_title( $query ) { if ( is_category() && $query->is_main_query() ){ // is_category() can specify a category, if necessary $query->set( 'orderby', 'title' ); $query->set( 'order', 'ASC' ); } } add_action( 'pre_get_posts', 'order_category_archives_by_title' );
It is advised to put all custom action hooks and filters inside your theme’s
functions.php
which makes your theme files clean.- This reply was modified 7 years, 9 months ago by Subrata Sarkar.
Forum: Developing with WordPress
In reply to: How do I pass values to my custom plugin from outsideThank you @bcworkz. I will try the way you advised.
Question to @latenighthacker
“This not the way how plugin works. You can neither use a plugin in different areas of website nor display it in any part of website” – I don’t get you. I developed a plugin which is added to a widget.
Please let me know why I cannot use this widget (in fact using the underlying plugin) in different part of my website?
Forum: Themes and Templates
In reply to: [Nisarg] Center EVERYTHING in SidebarThe little turquoise line is coming from here.
#secondary .widget-title::after { background-color: #009688; /* remove this line */ content: ""; position: absolute; width: 50px; display: block; height: 4px; bottom: -15px; }
In order to remove the turquoise line you need to either override or remove this line:
background-color: #009688;
.You can do one more thing. Increase width of the turquoise line so that it takes the width of widget area.
#secondary .widget-title::after { background-color: #009688; content: ""; position: absolute; width: 85%; /* Width increased to 85% */ display: block; height: 4px; bottom: -15px; }
However, either way you go, as mentioned by @addweb-solution-pvt-ltd, you better use a child theme otherwise updating the theme will erase your changes.
Hope this will help.
- This reply was modified 7 years, 9 months ago by Subrata Sarkar.
- This reply was modified 7 years, 9 months ago by Subrata Sarkar.
Forum: Themes and Templates
In reply to: [Hemingway] Category Page to have excerpts instead of full postYou have two different questions.
[A] “how to have the category pages to display only posts under that category”
[B] “with only excerpts showing up”This is how I did it. You may try once if haven’t already
[A]
1. Create a page
category.php
in your theme’s root folder
2. Get category object from current category title$cat_name = single_cat_title('', false); $term = get_term_by('name', $cat_name, 'category'); $cat_id = $this_cat->term_id;
Get posts for above category id (
$cat_id
). Better way is to create a custom function in yourfunctions.php
file.function get_posts_by_category_id($cat_id, $post_type, $records_per_page){ $currentPage = get_query_var('paged'); $args = array( 'category' => $cat_id, 'post_type' => $post_type, 'paged' => $currentPage, 'posts_per_page' => $records_per_page ); $posts = get_posts($args); return $posts; }
[B]:
Now inside your
category.php
call the function fromfunctions.php
:$posts = get_posts_by_category_id($cat_id, 'trips', 24); <?php foreach($posts as $post) : setup_postdata($post); ?> <div> <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a><br /> <?php the_excerpt(); ?> </div> <?php endforeach;?>
Hope this helps!
- This reply was modified 7 years, 9 months ago by Subrata Sarkar. Reason: Added code block
- This reply was modified 7 years, 9 months ago by Subrata Sarkar. Reason: Removed wrong placement of php tag
Forum: Themes and Templates
In reply to: [Portfolio Gallery] Post not showing under categoryHi Carlie,
Are the posts in question Published? If you are OK with WP_Query you can try this:$query = new WP_Query(array( 'post_type' => 'travelog', 'paged' => $currentPage, 'posts_per_page' => 3, 'orderby' => 'date', 'order' => 'DESC', 'post_status' => array('publish','future','pending') ));
The major
post_status
-es WP handles are:'publish' - a published post or page 'pending' - post is pending review 'draft' - a post in draft status 'auto-draft' - a newly created post, with no content 'future' - a post to publish in the future 'private' - not visible to users who are not logged in 'inherit' - a revision. see get_children. 'trash' - post is in trashbin.
Your posts should fall in any of the above statuses.
Forum: Themes and Templates
In reply to: [Twenty Fifteen] How can i change the background color of posts?How are you referencing your external custom CSS? Ideally it should be
enqueued
in your theme’sfunctions.php
like this:function include_static_resources() { wp_enqueue_style('custom-style', get_stylesheet_uri(), array(), mt_rand(), 'all'); ... } add_action('wp_enqueue_scripts', 'resource_includes');
And if the background rule is set in your
custom-style.css
it should work.Forum: Themes and Templates
In reply to: [Hiero] Blog post issueAre you using a template for your blog page?
Can you put the code here?