Wordpress post customising - php

i was wondering if this is feasible.
Supposing my i want to divide my post ... Lets say, i have all my post side by side in 2 rows.
Lets say a total of 8 from the category (Mypost)
Now assuming, i want to have a static between the first 2 rows and the rest of the columns below, is this feasible?
Also assuming i want latest post to show on the 2 up rows and the old post to move below my div.
I have tried , but did not come out with any feasible solution.
Great if someone could be able to assist. I have content.php where all my contents are being generated and index.php being the front end.
Thank you

using two WP query may help you ,use this one for latest post
<?php query_posts('category_name=Mypost&showposts=5');?>
And for the older posts use
<?php query_posts('category_name=Mypost&offset=5');?>
I really don't understand your problem clearly,hope this is what you want

THANK YOU Akhila - Ok, i needed to edit the code a little bit - This code works!:)
<?php query_posts('category_name=post&showposts=2'); ?>
<?php query_posts('category_name=post&showposts=100&offset=2'); ?>

Related

Last Post Function in wordpress

I made my website http://test.costa.io/?page_id=4, with wordpress and I put here all my post. The problem is that I want to have a function to check if its the last post, and if it's so dont put the /hr/.
I tried with the function more_post() and last_post but didn't make it work.
This is the code of the plugin I use to get all the post in the web :
http://pastebin.com/Qv9Ff2T7
You can get the number of posts you have by count($posts) and then add a counter variable in the foreach loop. When the counter is equal to the number of posts you know that it's the last post, so don't output the hr.
Ok I make it work changing the way I did it, still the count was a good way to do it, so ill give u the credit for it. Thanks everyone

views_embed_view('FeaturedSalesProperties','default')

I am new in drupal. and I have this piece of code:
<?php print views_embed_view('FeaturedSalesProperties','default');?>
in page-node-3167.tpl.php
it prints on site 3 random featured ads... and I do not understand what SELECT in DB is executed...
I found record in views_view with name FeaturedSalesProperties and base_table node but still do not know how this 3 ads are chosen...
Also it looks like the drupal site is modified because if i wanna access site/admin there is no drupal administration...
Can anybody explain me how can I modify this view so it will print not 3 random featured ads but all of them?
Thanks
Ok, so I found a way how to edit it without drupal administer... all values are in DB...
at first find your view in view_view table
second find in view_display record with the same vid as your view...
look into field display_options and that it is...
It is quite complicated to find which value to change but it is possible :D also it is helpful if you can create some view in other drupal system and watch what has been changed if you turn this option or this...

post form data to html table in DNN

I need your help
I have two pages in a DNN site. 1 is a form and 2 is a html table.
My question is. Is it possible to get the data from page 1 and send it to the table in page 2 in a DNN site? If so, do you know where I can find tutorials on how to do this?
Hope to hear from you.
Thanks!
If I understoud you right the answer is yes. (DNN module development is required)
NavigateUrl();
You can pass a TabID in this method to navigate to another page.
will help you reaching your goal.
you can add a string array as parameters into this method.
On page2 you can read out your parameters with the following code:
Page.Request[""];
type in the string of your named parameter.
This is a good way to transfer strings from page1 to page2.
If you want to transfer big object or something I would sugesst you that you should do it with a database or only transfering the string where you can read out your information in the DB.
The following link can help you but be carefull this is a VERY old state (about 5 years old created for DNN4 I think). Iam not sure if everything in this link is working.
DotNetNuke 4 NavigateURL examples
hope this helps.
best regards, noone.

<?php bp_activity_id() ?> in buddypress, anyone up to scratch?

I have been trying to sort this problem out for the last few days, here is an overview of my problem relating to
<?php bp_activity_id() ?>
I have 2 comment forms for a gallery plugin in buddy press, the first appears if there are no comments, and it 'creates' a activity it, the 2nd form appears if a comment has ever been made to and has the <?php bp_activity_id() ?> attached it it.
I would like to know how to automatically create a activity item as the first form cannot use features such as favorite or like as there is no id to associate with. I would like the 2nd form to be filled with an id, or in worst case scenario is it possible for some jquery/javascript to automatically add a comment and remove it ONCE (one time only) so that there is an ID? I can find more info if required, any really appreciate any help given!
$newActivity = bp_activity_add($args); // you dont NEED args, but you can pass them.
// $newActivity = the new activity's ID.
Source: http://www.buddydex.info/buddypress/bp-activity/bp_activity_add/

Wordpress- Displaying and layering custom fields/posts

I am somewhat new to both Wordpress and PHP, and I wanted to get advice on the best way to tackle my problem as I have had little luck doing it successfully so far.
There are two jobs I want to handle:
First of all, I want to have a conditional include on my home page that does the following;
Find a custom post type home_content (only ever going to be 1 post, which is ID 76 - if that helps)
Display 3 custom fields from that post... the values for today_on front_widget_a & front_widget_b
(I guess a secondary question would be - can I even pass shortcode through a custom field, because that's what those widgets are being generated from, is shortcode from a plug-in)
That's pretty much it. I've tried various combination of get_posts and get_post_meta without much success. Either I get some syntax errors I can't figure out (and trust me I've combed my code many times for missing semi-colons and the like). That or I get a result that makes no sense.
The second one is a bit more difficult.
Basically trying to turn a part of my Wordpress into a bit of a CMS-style feature. Basically, I have 2 additional custom post types, one called tag_page_layout and one called tag_page_data.
When a Tag in a post is clicked on, I want the Tag page to grab custom field 1 from the tag_page_layout, and then a couple custom fields worth of data from tag_page_data.
I probably wouldn't even need the two post types if I took the time to learn the PHP or HTML code for making tabs, but again, I'm using a plug-in for Wordpress shortcode (which, if you see above - I'm not even sure is going to work right - of course if its not I'm willing to make multiple of these 'layout' posts so each [tab:NAME] shortcode bit is in it's own post-content area.
So... the tag page will basically have a big bit of code that runs before the loop.... it knows its on a tag page so it starts loading Custom Field 1 from the tag_page_layout, which is essentially a bit of code that starts up a Tab-separated data presentation area. Then it's got to take the tag clicked and match it with the same tag ID from custom post type #2 - the tag_page_data group. Then it will grab the first 3 or so fields from that page, swap back to the layout post, throw another custom field from there to start another tab, and so on and so forth, until a [tab:END] and it runs the loop.
I could include all my various attempts and bits of code that never worked or half worked, but I've been around so many circles trying to construct this. Like I said, my coding knowledge is limited but I can usually feel my way around, however these finer points of trying to make Wordpress a little more CMS-like seem to be harder for me to grasp. Any help would be appreciated!
As far as using shortcodes in custom fields go, this should help you out, where XXX is your custom field name.
<?php
$var = apply_filters('the_content', get_post_meta($post->ID, 'XXX', $single = true) );
echo $var;
?>
This apply's the standard filters wordpress automatically runs on regular post content, allowing it to process your custom field and convert the shortcode.

Categories