Identifying instances of the same wordpress widget on a single page - php

I have altered the elementor posts widget to include a loop so I can have numeration for posts. How can I specify a single instance of that widget? For example, in category A archive, the posts in that category will have numeration but the overall Top 10 box will not even though they use the same widget. Is there a way to name and call each instance of the widget?
Currently, all instances of the widget have the same numeration. I would like them all to be different.

Related

Use a single wordpress category.php file for every category registered

As the title suggests, I'm trying to use one category.php file for every category registered by a user in the back-end. I've always created category-[specific category].php files in the past but this feels very messy as the design usually remains the same.
Without being specific in the query I return all posts in all categories however, I want to be able to show the custom posts for only the category selected from the nav. The problem is, I can't seem to find a way to pass the category the user selected into the query in order to only return posts attributed to it.
Thanks in advance for any help.
You don't need to do anything specific to show a list of posts from a specific category. Take a look at this article on the WordPress Codex. Here is an excerpt from that page:
In the case of categories, the hierarchy is fairly simple. For
instance, suppose the slug of the Category in question is news and the
Category ID is 6. The Template Hierarchy specifies that WordPress will
use the first Template file it finds in your current Theme's directory
from the following list:
category-slug.php
category-ID.php
category.php
archive.php
index.php
So all you need to do is create category.php in your theme and then view any category and it'll use that template. You can then use is_category() to check which category is currently being used if you want to do custom things depending on the category.

How to create single-custom.php for different repeater fields (using Advanced Custom Fields) in Wordpress

I'm using Advanced Custom Fields Pro with Wordpress 4.1.1
I feel like this should be pretty easy but I've been struggling with it.
The example I'll start with is I have a "Team" page that has a repeater with:
Profile Image
Name
Job title
Short biography
Email/social link
All as sub_field
I have everything working nicely in the page where all posts are display (the actual Team landing page) but I can't figure out how to get content for each employee to live in a single-custom_template.php with a permalink.
tl;dr I want my repeater content to be able to navigate to a single post/page with it's own custom template. Click on "Dave" in the whole team page have it navigate to his bio page.
I think you would benefit in building a custom post type for "Teams" so you're not selecting a new custom template (single-custome_"".php) each time you post another team member profile. This way also allows you to have all your custom meta fields organized under a single custom post-type. However, if you don't want to go through all the trouble in creating a custom post-type, you can post each single team member page as a child page to your parent "Team" page, so that the url would look something like, "yourdomain.com/team/team-name, and then have all your custom meta fields auto populate when you select the single-custom_template.php in the "template" dropdown field.

Adding 'active' class to wp_nav_menu when viewing post

I have a Wordpress site comprised mostly of pages, but there is one page (news section) that contains posts and categories like a blog would. I'm generating my nav using wp_nav_menu() with only the top-level pages displayed. I have styles set for the current link and the current link's parent that use the .current-menu-item and .current-page-ancestor classes that wp_nav_menu() automatically adds.
However, when you're viewing a post within the news section, no classes are added to the nav to indicate that you're in that section, and there's no way to style the "news" link to show that it's the section of the site the user is in.
Is there a way for WP to "know" that posts belong to that page? It's not a category because since no other sections of the site contain posts, the categories field is open and the editors can add whatever categories they want.
Do you have your "News" page set as your blog page, in the "Reading" settings? If so, it should add the class "current-menu-parent" and "current-post-parent" to the "News" <li> when you are viewing a post.
According to Wordpress template hierarchy (and specifically this diagram) a single post is being displayed by a file called single.php (or single-<post_type>.php. A set of posts from a category will be displayed by category-<post_type>.php template file.
Now, if you abide to this hierarchy, you'll have two more templates - news list and news detail page. Having two pages with these templates will make them automatically listed by Wordpress menu-generating function.
If that's not enough for you, you should use WP_Query to manually list your pages. If you decide to do it this way, one or two if statements should do the job.

How to colour wordpress menu lis based on category assigned to each page?

I would like to create a nav menu that displays all the pages of a wordpress site, its layout similar to what you would see in a footer sitemap layout, approx 5 columns with all the pages shown. Each page will be a project. I want to use wordpress category checkboxes (like you have for posts) to allow selection of one relevant category for each project page. Each page will then show a category caption below the project's description text, this I will style with CSS so each category has a different background colour.
Because Wordpress doesn't provide categories for pages, I have found a plugin to add this category feature to pages called ninja-page-categories-and-tags: http://wordpress.org/extend/plugins/ninja-page-categories-and-tags/
It's possible to edit the plugin php code under basic-functions.php to return a 'class' for the category displayed using get_slug and then applying css for each.
My problem is that on the menu, which will be a secondary menu in Thirty Ten displaying the pages, I want to be able to colour the background of each link to match the category that has previously been assigned to each page using the ninja plugin. Because the menu works with pages and the categories are not directly linked to the menu items (firebug will not show category details in the html of each link to reference with the css) I am wondering how I can colour each link based on category? Any ideas?
Ultimately what I would like to achieve is a grid of page links that are all coloured based on their category, a colour coded menu.
The plugin uses the standard wordpress category functionality but I just can't think how to connect these category details to the menu items to allow me to style them with css, any help would be really appreciated, even if just a point in the right direction.
Thanks
It's difficult to understand exactly what you're after, but essentially if you want to add extra classes to menu items (which will allow styling), you need to create a custom walker function.
Have a look at a tutorial like this: http://wp.tutsplus.com/tutorials/creative-coding/understanding-the-walker-class/

Make a Custom template for a specific category in wordpress

I am having issue with a custom category template. I want to create a new template for my specific category "VIDEOS" so that all posts under this category show in new style. Basically, i want to show posts with videos in a new way as 3 posts in one row with featured images and a featured slider on top of that page showing 4 new posts of that category ?
But i am confused... Can i do this in wordpress ? Because my home page also has a featured slider. Can i create a new slider for that page template but one thing is sure. I need to work with only one category for that custom template i.e. videos.........
Just create category-[id].php & you will be ready to use that. Wordpress will automatically load that file for that ID of category.
You can also do same task via slug like category-files.php etc as well
Yes, certainly possible with WordPress.
Find the slug or the category id. Your slug for the category may be videos. So create a custom template named category-videos.php. This template will be used for the category archive VIDEOS.
If you know the category id, you can create template named category-<category_id>.php.
For other people landing on this page and wondering what to do when they go to their theme's folder and don't find a file called "category.php", what you need is to find the next file in the hierarchy, copy it, and rename it category-[slug or id].php (this should be archive.php, followed by index.php).
For a listing of the category hierarchy, see the official documentation: http://codex.wordpress.org/Category_Templates

Categories