Buddypress register page pulling wrong template - wordpress

I have created a register page and tried to set a template for it by selecting the template from the dropdown in the right column ie: Page attributes->template (dropdown). When I view the register page the form is displaying correctly but it isn't using the template I set for the rest of the content. I can tell that it is instead using page.php from this snippet I used where it should be using template-other.php
function show_template() {
global $template;
print_r($template);
}
add_action('wp_footer', 'show_template');
The funny thing is that if I change the URL to a capital ie: from example.com/register to example.com/Register then it uses the right template but the buddy press form doesn't show up. But if I use example.com/register then the form shows up but it doesn't use the template I set. Any suggestions would be greatly appreciated.

Related

Wordpress template for specific nested page

In Wordpress I have a page with the slug logged-user with a parent page ecadmin, making it accessible under the URL /ecadmin/logged-user/.
Since it has a parent page, I (or any other user) can create a page with the same slug logged-user as long as it isn't nested under the same parent page.
The problem now is that I cannot create a single page template page-logged-user.php in theme's folder, as this template can be potentially applied to any other page named logged user no matter where it belongs hierarchly.
Is there a way to name the template file in such way that is referencing to its parent page(s) as well? E.g. page-ecadmin-logged-user.php
The feature you are hoping for doesn't exist, but there is a quite simple way to accomplish what you want to do:
You can create a custom page template [whatever-you-want].php and place this comment in the header
/*
Template Name: Logged In User
*/
That template will be available in the Page Attributes meta box for any "Page" in Wordpress, but will only be applied to a given page if selected in that meta box.
Note:
All content creators have access to the page attributes meta box by default.
If you are worried about users applying that template inappropriately you could hide the Page Attributes meta box from everyone who isn't an admin:
function remove_post_custom_fields() {
if (!current_user_can( 'create_users' )){
remove_meta_box( 'pageparentdiv' , 'post' , 'normal' );
}
}
add_action( 'admin_menu' , 'remove_post_custom_fields' );
http://www.wpbeginner.com/wp-themes/how-to-create-a-custom-page-in-wordpress/
You could try using using page-$id.php which would be unique to that page.

Multiple thumbnails in WordPress based on page template?

Is there a way to add multiple thumbnails in a page based on page template or page ID
instead of post type (post, page)?
You can add a conditional statement to test for a specific page id:
if(is_page('<your page id>')){
// Do your thing
}
Similarly, you can test for a specific page template like so:
if(is_page_template('<page template file name>']){
// Go on wit' you bad self
}
Make sure that when you use is_page_template() that you feed it the file name of the template, e.g., is_page_template('two-columns.php'), as opposed to the name of the template, e.g., is_page_template('Two Columns').

Drupal - Template for Custom Page

I've got a custom page I created programmatically using hook_menu. I can have it return content without a problem. However, I want it to appear within the content region of my page.tpl.php template so that blocks can be incorporated in the page. Same way that Views allows you to give a view a custom url while still appearing in the page.tpl.php template.
How do I do this for my page? By default, I just get a with only my content.
Thanks,
Howie
In your page callback function, if you just print the content of your page without returning anything, it won't be included within your page.tpl.php. If you return a string containing the contents of your page, it will go into the content region, i.e.
function mymodule_page_callback () {
$content = "Hello, world inside the content region";
return $content;
}

Can WordPress post content be external data (not from the database)

I am trying to display a page based on some data returned from an external API (Amazon). This data is formatted then, has to be displayed on a page, created on the fly, based on URL querys. I can already do this with shortcodes but this has to be from the query.
I see all kinds of info in the codex on returning custom query_posts into the loop from the database. However, I cannot find info getting external data to appear on a page.
Is this possible in WordPress? (anything is possible, right?) Just point me to some functions, filters or tutorials please.
If I understand you correctly, you want to retrieve data dynamically and display it in a WordPress page?
There are many ways to do this, but here's one option:
Create a Page Template
Create a WordPress page and use the Page Template created in step 1.
Edit the Page Template to call the external API and display the data
I'm guessing you've been trying to find a way to do this from the "content" of a page or post, but the easiest way is to put the code in a custom Page Template.
UPDATE: If you want to programmatically create a page, this might work for you: http://wordpress.org/support/topic/how-to-create-pages-programmatically?replies=5#post-1230619
http://www.prelovac.com/vladimir/wordpress-shortcode-snippet-to-display-external-files
This is a snippet to display external data in a post.
Would this help? If the dynamic page was a HTML page and THEM displayed in WP.
Yep, Thats possible.
I Did by using bridges.
You can do it by add "add_meta_boxes" action.
Inside the meta box function you can add call and get the external page contents, or can give your own forms .etc
My Code :
/*
* Add Meta Product Type Field to POST
*/
add_action('add_meta_boxes', 'meta_box_product_type_add');
My Meta Box
/*
* Product Type Meta Box Init
*/
function meta_box_product_type_add()
{
add_meta_box('ptype_testing', 'Product Type', 'add_ptype', 'testing', 'normal', 'high');
}
/*
* Product Type Field
*/
function add_ptype()
{ ?>
<label>Type of Product : </label>
<select name="ptype" id="ptypes">
<option>----Select----</option>
<option>Physical</option>
<option>Virtual</option>
</select>
<label>Unit :</label>
<select name="punit" id="units">
<option>----Select----</option>
<option>KG</option>
<option>Mtr</option>
<option>Ltr</option>
</select>
<?php
}
Try It....

WordPress - how to insert html code selectively in posts

I want to display custom html code when a post is rendered (so not when is inserted into the database).
I currently do this with add_filter('the_content', 'my_custom_method'). The only problem is that I want this do be displayed only inside the post (when is viewed in its own page), not when all posts are rendered .
I banged my head against the wall, but couldn't find any method to tell me if i'm currently inside an individual post or not (this has to work for every url rewriting possible, so i can't rely on url)
Is there such a method? I believe it should be, but i can't find it. Thanks.
the function for checking if the post is in its own page is is_single()
add_filter('the_content', 'my_custom_method');
function my_custom_method(){
if(is_single()){
//code for your custom html code
}
}
the function is_single() checks if the page being rendered is a single page or not.
The easiest way to do this would be to modify your templates. Wordpress template sets should have a file named single.php (inside wp-content/themes/<theme name>). This is the page that gets rendered when you are viewing the page for a single post.
You could edit this file and insert whatever you needed to for the posts there.

Resources