Archive for the ‘Programming’ Category
WordPress: get posts within the loop
Posted by Dimitri | Filed under Programming
This post will explain how to get posts at the WordPress loop, so you can place code (probably advertisement code) after a specific post (first, second, third) or at intervals (e.g.: every 3 posts).
Before starting, it is a good idea to create a backup copy of your theme’s index.php file, just in case anything goes wrong.
This is a five page post, so here is the page index:
- Get the first post
- Get the 2nd, 3rd or any other post
- Get odd/even posts
- Get post intervals
- Final considerations
Let’s begin by finding where to place the code. That’s why we need to find the WordPress Loop in the index.php file.
Continue reading: “WordPress: get posts within the loop”
Access Activity class from View
Posted by Dimitri | Filed under Featured, Programming
So, it begins! This is the first on this blog!
Let’s start with a Android Programming tip: how to access the Activity from an instantiated View object.
The first thing to do is consider if you really need to call an Activity from a View. Take some time to analyze your classes and their relationships. Probably, the variable/method you need to access doesn’t have to be a member of the Activity class. In that case, think about placing that variable/method inside the View or create a new class that has variables/methods which can be accessed by both Activity and View. Unless an Activity variable or method (e.g. Activity.finish() ) needs to be called from the View, there is no need to try to access the Activity from the current View.
But if you need to access a method/variable of the calling Activity from the View, here is how it’s done: