Daniel Gilfoy
Forum Replies Created
-
Forum: Themes and Templates
In reply to: current_user_can not working with custom rolesI’m guessing not. I don’t see anything on trac, so I’m guessing nobody has submitted it as a bug. Should we?
I’m trying to assign Administrator custom capabilities and find that I cannot. Do I need to create a custom role, assign it the all of the same capabilities as Administrator PLUS my custom capabilities just to test these new capabilities with current_user_can()?
I’d rather not. Why can’t we test custom capabilities with current_user_can? We need a new function register_capability() or something.
Forum: Fixing WordPress
In reply to: Posts on PagesMy solution:
Create a page template for the teacher’s pages. In there, keep the loop unchanged from your theme’s page loop.
After that loop, do a WP_Query for posts belonging to an author.
Here’s the trick to keep it dynamic. Use a custom field to the teacher page and call it something like “teacher_id” and do something like this: https://pastebin.com/UeLj0Z9C
Forum: Fixing WordPress
In reply to: Display Custom Field Data In LoopThe short answer:
<?php echo get_post_meta($post->ID,’custom-field-name’,true) ?>??
Forum: Fixing WordPress
In reply to: Show sidebar to dynamic page that will be edited?Hmm, not sure what you mean. Let me see if I get what you want.
On the “Whats On” page (classes), you want to pull the usual data in the main content area (left column). This works already. (I’m assuming)
In the sidebar you want editable content (hence the page), which you can call “Whats on sidebar” as the page or post title, or whatever you want.
The code I gave you for your sidebar will not affect the main content (left side). It will pull from a separate page or post, and place the content you want in the sidebar (right side).
You can put that code in the classes.php template file if you want. I only suggested you put it in a separate sidebar-classes.php file for re-usability, in case you wanted to use the sidebar on another page for some reason.
Forum: Fixing WordPress
In reply to: How do I take index.php out of my urlAre you on a windows server?
If so, see this.
Forum: Fixing WordPress
In reply to: Show sidebar to dynamic page that will be edited?No problem Nash! It should work as a page or a post with p=id. If not, add ,”post_type”=>”page” right after “p”=”x”
Forum: Fixing WordPress
In reply to: Show sidebar to dynamic page that will be edited?Here’s what I’d do. create a separate sidebar-classes.php file. Then in your classes.php template file, do <?php if ( function_exists(‘dynamic_sidebar’) && dynamic_sidebar(classes) ) : else : ?>
<?php endif; ?>and in the sidebar-classes.php do: https://pastebin.com/nAZjW1KL
replace the p=”x” with the id of the post you want to pull in.
edit: oops, error, edited the pastebin. It’s early here, lol.
Forum: Fixing WordPress
In reply to: Show sidebar to dynamic page that will be edited?There are a few ways you could do this:
- Assign a page or a post as the content for the sidebar. In the sidebar3.php page, create a WP_Query or get_post() loop and pull that content in.
- Use a text widget or something
- Use a Plugin (don’t know of any specifically at this time though)
I’d personally recommend the first option.
Forum: Fixing WordPress
In reply to: Help needed with header code pleaseLooks like you need to call global $post; before you use the $post->ID. You can only access the $post global in the loop without calling the global first, IIRC.
Forum: Fixing WordPress
In reply to: Show sidebar to dynamic page that will be edited?I didn’t, I was just looking at the DOM element where your sidebar would be.
As for the sidebar, you will need to add that snippet to sidebar.php, you can’t add it through a WordPress page or in a widget unless you specifically have a plugin that allows php execution in WordPress pages/widgets.
Forum: Fixing WordPress
In reply to: Show sidebar to dynamic page that will be edited?You need to bump down the #whats_right width attribute. 380px works for me.
Forum: Fixing WordPress
In reply to: register activation – Add terms to taxonomy? (custom post types)Pfft. I apparently didn’t look hard enough. Found the solution this morning:
wp_insert_term();
Forum: Fixing WordPress
In reply to: WP_Query in add/edit page (adding custom meta box)Made a solution, still interested in a WP_Query solution if there was one. Making the changes as requested sill resulted in the PAGE title, content and revisions overwritten by the “last” Featured Resident category POST.
Anyway, my solution works just fine, so I’ll call it resolved. Feel free to offer suggestions as to why this happens. I’m completely stumped.
Forum: Fixing WordPress
In reply to: WP_Query in add/edit page (adding custom meta box)Yes, I’m getting the original post’s custom data.
So in this example, I have the About page. When I edit the about page, I want a meta box that has all posts in the “featured residents” category and be able to select one. On the front end, when a person views the about page, they will see the person I selected (the post data which is about that person anyway). This data will actually be in the sidebar with a link to read more – with a link to the post itself.
The custom meta information (the ID of the post I selected), is saved in the About page, under it’s ID, under it’s custom meta.
I’ll try changing my WP_Query to what you suggest, but I don’t see how it is taking the information from the posts and filling the page data with it.
Forum: Fixing WordPress
In reply to: Home Page showing "blog" despite settingsIf I set my Reading settings to “Show Posts” it shows my homepage. Any idea on what is causing this?
All plugins are disabled and the plugins_active field in wp_options is set to a:0:{} as suggested in the codex to ensure no plugins are being a ninja.
Edit: Nope, never mind. That didn’t work, it just appended /home/ to my url and I wasn’t paying attention.